0

I'm using Windows.

I've installed mongodb module using next command:

npm install -g mongodb

mongodb module is listed when I type:

npm ls -g

But when I'm trying to do require('mongodb'); Node gives me an Error: Cannot find modue 'mongodb'. When I include mongodb with absolute path it's included fine:

require('C:\\Users\\Evgeniy\\AppData\\Roaming\\npm\\node_modules\\mongodb');

Any ideas what I'm doing wrong?

2 Answers2

1

Well, this must be caused by environment variables. You have to set NODE_PATH to C:\Users\Evgeniy\AppData\Roaming\npm\node_modules.

majidarif
  • 18,694
  • 16
  • 88
  • 133
0

You can run following commmand from command prompt:
setx NODE_PATH %APPDATA%\npm\node_modules

This will set the environment variable permanently in your user profile's environment settings

AIyer
  • 106
  • 1
  • 7