Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js, Error: Cannot find module 'express'

It says

Cannot find module 'express'

Do you have express installed? If not then run this.

npm install express

and run your program again.


After you do express in your terminal, then do

npm install

To install all the dependencies.

Then you can do node app to run the server.


Check if you have installed express module. If not, use this command:

npm install express

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

set NODE_PATH=your\directory\to\node_modules;%NODE_PATH%

npm install --save express

This worked for me. Just run express.js installation again.


npm install from within your app directory will fix the issue as it will install everything required


Unless you set Node_PATH, the only other option is to install express in the app directory, like npm install express --save. Express may already be installed but node cannot find it for some reason