gpt4 book ai didi

javascript - 无法启动我的 nodejs 应用程序

转载 作者:行者123 更新时间:2023-11-30 15:38:11 25 4
gpt4 key购买 nike

您好,我正在尝试启动一个基于 node-js 的应用程序,但它给了我一些基于 mongodb 的错误,我似乎无法启动我的插件。

错误:

/home/jira-Plugins/cloud/test-plugin/node_modules/mongodb/lib/server.js:110
if(host.indexOf('\/') != -1) {
^
TypeError: Cannot call method 'indexOf' of undefined
at new Server (/home/jira-Plugins/cloud/test-plugin/node_modules/mongodb/lib/server.js:110:11)
at new MongoDB (/home/jira-Plugins/cloud/test-plugin/node_modules/jugglingdb-mongodb/lib/mongodb.js:51:18)
at Object.initializeSchema [as initialize] (/home/jira-Plugins/cloud/test-plugin/node_modules/jugglingdb-mongodb/lib/mongodb.js:26:22)
at new Schema (/home/jira-Plugins/cloud/test-plugin/node_modules/jugglingdb/lib/schema.js:106:13)
at Object.<anonymous> (/home/jira-Plugins/cloud/test-plugin/app.js:56:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3

以下是我目前使用的配置:数据库.js

module.exports = {
url : 'mongodb://localhost/test'
};

应用程序.js:

var mongoose = require('mongoose');

/*var methodOverride = require('method-override'); // simulate DELETE and PUT (express4)*/
var database = require('./config/database');
/*var port = process.env.PORT || 8888;*/ // set the port

mongoose.connect(database.url);
console.log('Connected to Database: ' + database.url);

var Schema = require('jugglingdb').Schema;
var schema = new Schema('mongodb');

var schema = new Schema('mongodb', {
url: 'mongodb://localhost/test',
});

我还在我的应用程序中使用 jugglingdb 作为 crossDb ORM

配置.json

"store": {
"adapter": "jugglingdb",
"type": "mongodb"

},

如果错误已完全改变,我实现建议后:

Unhandled error: TypeError: Cannot call 

method 'indexOf' of undefined
at new Server (/home/jira-Plugins/cloud/test-plugin/node_modules/mongodb/lib/server.js:110:11)
at new MongoDB (/home/jira-Plugins/cloud/test-plugin/node_modules/jugglingdb-mongodb/lib/mongodb.js:51:18)
at Object.initializeSchema [as initialize] (/home/jira-Plugins/cloud/test-plugin/node_modules/jugglingdb-mongodb/lib/mongodb.js:26:22)
at new Schema (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/node_modules/jugglingdb/lib/schema.js:105:13)
at /home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/lib/store/jugglingdb.js:34:32
at lib$rsvp$$internal$$initializePromise (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/node_modules/rsvp/dist/rsvp.js:541:9)
at new lib$rsvp$promise$$Promise (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/node_modules/rsvp/dist/rsvp.js:757:9)
at new JugglingDB (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/lib/store/jugglingdb.js:32:18)
at module.exports (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/lib/store/jugglingdb.js:168:10)
at Function.stores.create (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/lib/store/index.js:18:10)
at stores (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/lib/store/index.js:12:17)
at EventEmitter.Addon (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/lib/index.js:31:38)
at module.exports (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/lib/index.js:204:12)
at Object.<anonymous> (/home/jira-Plugins/cloud/test-plugin/app.js:32:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
Unhandled error: TypeError: Cannot read property 'settings' of undefined
at JugglingDB.proto.isMemoryStore (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/lib/store/jugglingdb.js:78:29)
at EventEmitter.exports.shouldRegister (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/lib/internal/registration.js:45:67)
at /home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/lib/internal/registration.js:85:54
at lib$rsvp$$internal$$tryCatch (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/node_modules/rsvp/dist/rsvp.js:493:16)
at lib$rsvp$$internal$$invokeCallback (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/node_modules/rsvp/dist/rsvp.js:505:17)
at /home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/node_modules/rsvp/dist/rsvp.js:1001:13
at Object.lib$rsvp$asap$$flush [as _onImmediate] (/home/jira-Plugins/cloud/test-plugin/node_modules/atlassian-connect-express/node_modules/rsvp/dist/rsvp.js:1198:9)
at processImmediate [as _immediateCallback] (timers.js:330:15)

最佳答案

您没有在 app.js 的第 56 行包含任何信息。

该错误看起来像是 mongodb 驱动程序试图在名为 host 的变量中查找斜杠,但由于 host 未定义而未能找到。

不是因为你定义了两次 var schema 吗?

var schema = new Schema('mongodb');

var schema = new Schema('mongodb', {
url: 'mongodb://localhost/test',
});

也许删除第一个你没有url的。

此外,您是否在同一个程序中同时使用 Mongoose 和 JugglingDB?

关于javascript - 无法启动我的 nodejs 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41210167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com