节点OracleDB错误:无法find指定的过程

使用OracleDB时出错Error“指定的程序找不到”.Node安装OracleDB经历的很好。 为构build执行的步骤是 已安装Visual Studio 2017 Visual C ++ 14.0 下载并遵循oracle即时客户端和sdk,添加了OCI_BIN和OCI_INC npm安装npm @ latest npm install node-gyp -g(在这之前删除了c:\ users \ .node-gyp npm安装oracledb OCI_INC_DIR指向“C:\ Oracle \ instantclient \ lib \ msvc” OCI_LIB_DIR指向'C:\ Oracle \ instantclient \ include'npm done的用于oracledb@1.13.1 运行具有node app.js /app.js内容的代码时出错 var oracle = require("oracledb"); console.log(oracle) Windows 8.1 x64 64 Bit OS gyp info using node-gyp@3.6.2 gyp […]

Express正在发送一个对象,里面有一个对象

我有一个连接到Mongoose数据库的Express服务器(我的术语可能不正确,因为我刚开始学习Express)。 当我访问一个/pipe理员(路线?)我收到一个对象与我的JSON对象里面。 我发错了吗? var userSchema = new Schema({ firstName: {type: String, trim: true}, lastName: {type: String, trim: true}, classYear: Number, email: {type: String, unique: true, sparse: true, trim: true}, phone: {type: String, unique: true, sparse: true}, phoneProvider: {type: String, trim: true}, isAdmin: {type: Boolean, index: true}, isSuperAdmin: {type: Boolean, index: true}, hash: String, companyName: {type: […]

将$ ajax转换为PUT请求的提取()

我试图翻译下面的jQuery代码来使用抓取API。 它发出一个PUT请求: function save () { $.ajax('/{{user.username}}', { method: 'PUT', data: { street: $('#street').val(), city: $('#city').val(), state: $('#state').val(), zip: $('#zip').val() }, complete: function () { cancel() location.reload() } }) } 这是抓取API请求: fetch('/{{user.username}}', { method: 'PUT', headers: { 'Content-Type': 'application.json' }, body: JSON.stringify({ street: document.getElementById("street").value, city: document.getElementById("city").value, state: document.getElementById("state").value, zip: document.getElementById("zip").value }) }).then(() => { cancel() […]

socket.io不工作没有错误显示

我正在使用node.js,socket.io和express来处理聊天应用程序。 我正在使用pm2来运行server.js。 在日志上说 0|server | 18-08 12:14:47.128: Server listening on port 3000 在控制台中也没有错误。 这是我的代码。 请忍受我,因为我仍然是一个新手在node.js和socket.io。 每一个帮助将不胜感激。 server.js process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; var app = require('express')(); var https = require('https'); var fs = require('fs'); var ssl_server_key = '/data/web/chat/app/node/server_key.pem'; var ssl_server_crt = '/data/web/chat/app/node/server_crt.pem'; var server = https.createServer({ key: fs.readFileSync(ssl_server_key), cert: fs.readFileSync(ssl_server_crt), NPNProtocols: ['http/2.0', 'spdy', 'http/1.1', 'http/1.0'] }, app); […]

即使本地主机存在于/ etc / hosts(MacOS El Capitan)中,我也会在运行简单节点服务器时获得`getAddrInfo ENOTFOUND localhost`

设置和运行普通节点js服务器时,发生了一件非常奇怪的事情。 当我运行node server.js ,我得到以下错误: Server running at http://localhost:1337/ events.js:160 throw er; // Unhandled 'error' event ^ Error: getaddrinfo ENOTFOUND localhost at errnoException (dns.js:28:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26) 当我在浏览器中打开http://localhost:1337/时,表示page does not exist 。 当我运行sudo node server.js ,它运行正常,没有任何错误,我可以访问我的网站在https://localhost:1337 这是我的/ etc / hosts文件: 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 我的server.js: // Require what we need […]

NPM package-lock.json导致npm install在Linux上失败

所以我刚更新了我的Mac上的NPM,并在一个项目上生成了一个locking文件。 “嘿 – 那太好了”我说,并且承诺。 然后,我的构build在Travis CI上失败,如下所示: Compiling Frontend Assets npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm ERR! Linux 4.4.0-83-generic npm ERR! argv "/home/travis/.nvm/versions/node/v7.4.0/bin/node" "/home/travis/.nvm/versions/node/v7.4.0/bin/npm" "install" npm ERR! node v7.4.0 npm ERR! npm v4.0.5 npm ERR! shasum check failed for […]

存根内部function?

我想在unit testing时在我的代码中存储一个内部函数,例如: //foobar.js const uuid = require('uuid'); function foo() { console.log('uuid: ' + uuid.v4()); // Lots of timers } exports._foo = foo; function bar() { //Logic… foo(); //Logic… } exports.bar = bar; 而unit testing: // test/foobar.js const chai = require('chai'), expect = chai.expect, proxyquire = require('proxyquire'), sinon = require('sinon'); describe('bar', () => { it('call foo', […]

信号量等同于Node js,variables在并发请求中被修改?

我在过去的一个星期面对这个问题,我只是对此感到困惑。 保持简短的解释问题。 我们有一个内存模型,它存储像预算等值。现在,当一个API的调用它有一个与其相关联的花费。 然后,我们检查内存模型,并将花费添加到现有的花费,然后检查预算,如果超过,我们不会再接受该模型的更多点击。 对于每个调用,我们也使用db,但这是一个asynchronous操作。 一个简短的例子 api.get('/clk/:spent/:id', function(req, res) { checkbudget(spent, id); } checkbudget(spent, id){ var obj = in memory model[id] obj.spent+= spent; obj.spent > obj.budjet // if greater. obj.status = 11 // 11 is the stopped status update db and rebuild model. } 这用于工作正常,但现在与并发请求我们得到错误的花费增加超过预算,并在一段时间后停止。 我们用j米模拟了这个电话,发现了这个。 就我们所能看到的,当状态更新到11时,节点是asynchronous的,许multithreading已经更新了活动的花费。 如何为Node.js提供信号量逻辑,以便可变预算与模型同步 更新 db.addSpend(campaignId, spent, function(err, data) { campaign.spent […]

Sequelize findOne错误:TypeError indexOf undefined

第一次使用一个新的数据库使用sequelize,通过cli完成表创build和迁移(我们有一个传统的数据库模式使用它,没有问题与模型构build匹配现有的表,所以我熟悉的基本用法) 。 当我试图testing一个新的表中的一个查询时,我得到一个typeerror。 系统:Sequelize v4.5.0,Node v8.1.4,npm v5.3.0 首先Stacktrace: TypeError: Cannot read property 'indexOf' of undefined at attributes.map.attr (**PATH**/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1222:27) at Array.map (native) at Object.escapeAttributes (**PATH**/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1207:37) at Object.selectQuery (**PATH**/node_modules/sequelize/lib/dialects/abstract/query-generator.js:979:28) at QueryInterface.select (**PATH**/node_modules/sequelize/lib/query-interface.js:672:27) at Promise.try.then.then.then (**PATH**/node_modules/sequelize/lib/model.js:1539:34) at tryCatcher (**PATH**/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (**PATH**/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (**PATH**/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (**PATH**/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (**PATH**/node_modules/bluebird/js/release/promise.js:693:18) at Async._drainQueue (**PATH**/node_modules/bluebird/js/release/async.js:133:16) at Async._drainQueues (**PATH**/node_modules/bluebird/js/release/async.js:143:10) at […]

在Node.JS上的Socket.io之间实现一个队列

我已经使用Node.JS和Socket.io写了一个聊天。 聊天很简单:总是有两个人的房间,一个员工和一个客户。 现在我们的容量正在成长,我们正面临一些问题,如networking问题上的消息“消失”,我们希望在我们公司和我们的客户之间实现一个排队。 就像是: 对于图片上的每个NodeJS进程,我们有6个虚拟机位于负载均衡之后。 我想知道什么是使用队列的最佳方法。 我应该在每个房间的队列中创build一个主题吗? 例如:对于用户C和D之间的交互,它将使用消息/ c:d ; 对于用户A和B之间的交互,它将使用消息/ a:b 。 或者最好使用没有任何主题的单个队列,发布/订阅消息中的所有消息并为每个订户进行广播? 如果订户有房间,他将处理该消息。 在第一种方法中,我不确定我应该如何使用MQ客户端,因为我通常初始化它们并让它运行。 当我想要创build一个caching来存储MQClient时,每个客户端将负责一个主题,在我的脑海里听起来很奇怪 – 如果我有10k个房间,我将有10k个MQclient。