Node.js Error: Cannot find module express

Node.js Error: Cannot find module express

You need to install Express locally into the context of your application (node_modules folder):

$ npm install express

The reason for this is that applications always look in their local context for any dependencies. The global installation is only for setting up system-wide available binaries, such as unit test runners or bootstrappers or things like that.

With Express, when you install it globally, you get an express binary that can bootstrap an application for you. For more information, type

$ express --help

So, to answer your final question: YES, you need to install it without -g.

For me it worked when installed express locally with –save option as follow:

$ npm install express --save

Node.js Error: Cannot find module express

Check if you are not install express module, use this command:

 npm install express

and if your node_modules directory is in another place, set NODE_PATH envirnment variable:

 set NODE_PATH=yourdirectorytonode_modules;%NODE_PATH%

Leave a Reply

Your email address will not be published.