我在YouTube上看了一个两年前的教程,我一直在这里。
throw error;
^
SetOptionError: mongodb+srv://BilalAhmed:password/Test: "mongodb+srv://BilalAhmed:password/Test" is not a valid option to set
at Mongoose.set (F:\Webdevelopment\Node JS\node_modules\mongoose\lib\index.js:249:17)
at Object.<anonymous> (F:\Webdevelopment\Node JS\NodeWithMongoDB.js:5:10)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
errors: {
'mongodb+srv://BilalAhmed:password/Test': SetOptionInnerError [MongooseError]: "mongodb+srv://BilalAhmed:password/Test" is not a valid option to set
at Mongoose.set (F:\Webdevelopment\Node JS\node_modules\mongoose\lib\index.js:251:33)
at Object.<anonymous> (F:\Webdevelopment\Node JS\NodeWithMongoDB.js:5:10)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
}
}
const mongoose = require('mongoose')
mongoose.set('mongodb+srv://BilalAhmed:password/Test',
{
useNewUrlParser: false,
useUnifiedTopology: true
}).then(() => { console.warn("Mongodb connected") })
我只想连接Mongo DB服务器并执行CRUD操作。
1条答案
按热度按时间yuvru6vn1#