您好我正在尝试启动基于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
以下是我目前使用的配置: database.js
module.exports = {
url : 'mongodb://localhost/test'
};
app.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
config.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)
答案 0 :(得分:2)
您没有提供有关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?