-
Notifications
You must be signed in to change notification settings - Fork 16
require('mongodb') fails #45
Comments
Looks like the "file" fs.js is built into the VS Code app. That file (as displayed in the VS Code editor) is NOT editable and I could not find it anywhere in my entire file system. So I edited the files that called it. The following 3 file edits were enough for my JS app to start to run INSIDE VS Code: node_modules/require_optional/index.js added line 70: return undefined; My js app can not connect to my atlas-based mongodb instance. Once connected, I can add and retrieve data from my instance. |
The same issue on Win 7 with newest VS version 1.21.1 Error: ENOENT: no such file or directory, stat 'c:\MyProjects\adminsema\server\node_modules\require_optional\index.js\package.json' Can not debug app in VS! |
It seems I found solution :) If uncheck flag All Exception for Breakpoints in Debug tab everything works ok. |
New to Visual Studio Code, new to Node.js and new to mongodb. I am running OS X 10.12.X
My mongodb is an instance on atlas, so the mongo server is NOT running locally.
node --version is v9.2.1
I can connect to my mongodb using the shell access tool from mongdb. I can connect to my mongodb instance using a PHP script on my computer.
I can invoke my js script via the command-line / node, and it connects to my mongodb instance.
However, when I invoke my js script from inside Code, I get this error as reported in file "fs.fs" and in the function "fs.existsSync":
Exception has occurred: Error
Error: ENOTDIR: not a directory, stat '/Users/gene/MusicDB/node_modules/require_optional/index.js/package.json'
at fs.existsSync (fs.js:346:13)
at find_package_json (/Users/gene/MusicDB/node_modules/require_optional/index.js:14:9)
at find_package_json_with_name (/Users/gene/MusicDB/node_modules/require_optional/index.js:34:20)
at require_optional (/Users/gene/MusicDB/node_modules/require_optional/index.js:69:13)
at Object. (/Users/gene/MusicDB/node_modules/mongodb-core/index.js:8:20)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
I am able to connect to a locally-running mysql server from inside Code. I've installed several other npm packages just to see if I could use them, and none of them have had any problems. Only the mongodb package appears to have an issue. I have since removed all references to node and npm and did a fresh install with only "mysql" and "mongodb" being installed by me. Still, no luck.
The text was updated successfully, but these errors were encountered: