Following message appears on my vscode terminal (code below!)
MongoDB shell version v4.0.10 connecting to: mongodb://DB%5Cmongo%5Cnode_modules%5C.bin%5C:27017/test?gssapiServiceName=mongodb 2020-09-15T18:51:58.260+0800 E QUERY [js] Error: couldn't connect to server DB\mongo\node_modules.bin:27017, connection attempt failed: HostNotFound: Could not find address for DB\mongo\node_modules.bin:27017: SocketException: No such host is known. : connect@src/mongo/shell/mongo.js:344:17 @(connect):2:6 exception: connect failed internal/modules/cjs/loader.js:968 throw err;
Error: Cannot find module 'C:\Users\Lim Family\Desktop\node\lecture\nodemon\bin\nodemon.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15) at Function.Module._load (internal/modules/cjs/loader.js:841:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }
While running npm start which runs "nodemon app.js" as defined in package.json. I've set IP address whitelist to all IP addresses. Additionally user and connection string simply copied paste from mongodb atlas.
Can someone explain where the error is, and also for the second error, cannot find module...., ive created a fresh project and installed all the dependencies but that one wont go away. Might be just me but i think nodemon is not running properly as well, doesnt have the [nodemon] prefix
[edit] now getting a different error:
MongoDB shell version v4.0.10 exception: Database name cannot have reserved characters for mongodb:// URL: mongodb://127.0.0.1:27017/DB%5CNew internal/modules/cjs/loader.js:968 throw err; ^
const mongoConnect = (callback) => {
MongoClient.connect(
"mongodb+srv://wesleynodejs:(passwordICopiedFromMongoDb)@learning.2fvkd.mongodb.net/test?retryWrites=true&w=majority"
)
.then((client) => {
console.log("CONNECTED TO MONGODB");
_db = client.db();
callback();
})
.catch((err) => console.log(err));
};