Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Express module not found when installed with NPM

When I try to run the app.js file created by express, I get the following error:

$ node app.js  node.js:134         throw e; // process.nextTick error, or 'error' event on first tick         ^ Error: Cannot find module 'express'     at Function._resolveFilename (module.js:320:11) 

When I type in express --version I get a return statement of 2.3.3. I used npm to install express. I had to manually make npm using these instructions:

git clone http://github.com/isaacs/npm.git cd npm sudo make install 

The error is Error: Cannot find module 'express'.

Do I need to do something after installing npm and express in order to make express see the modules created by npm?

  • My node is version: 0.4.6
  • My express is version: 2.3.3
  • My npm is version: 1.0.6

Express is installed globally. I used the -g flag to install it.


Edit: When I try "node -e require.paths" I get:

[ '/home/user/.node_modules',   '/home/user/.node_libraries',   '/usr/local/lib/node' ] 

So, node isn't detecting the npm installation. How do I get node to detect the npm installation?

like image 758
Kelp Avatar asked May 07 '11 07:05

Kelp


People also ask

Can not find the Module express?

To solve the error "Cannot find module 'express'", install the package by running the command npm install express in the root directory of your project. If you don't have a package. json file, create one by running npm init -y . The error occurs when we try to import the express package without installing it.


1 Answers

  • Install express

    npm install -g express

  • Create a new app

    express your_app

  • cd into app directory

    cd your_app

  • use npm link to resolve modules

    npm link express

like image 107
just_a_dude Avatar answered Oct 02 '22 12:10

just_a_dude