Getting error, Error: Cannot find module ‘express’ after npm install

kotoole

I am new to both Node JS and express, and I have just installed npm in Windows 7.

I have installed express using the global flag:

npm install -g express

This sucessfully installs express in C:\Users\USER_NAME\AppData\Roaming\npm\node_modules\express, and adds C:\Users\USER_NAME\AppData\Roaming\npm to my path.

However, using express in the command line is not successful. Any command starting with express tells me it cannot find the command to execute:

 'express' is not recognized as an internal or external command,
  operable program or batch file.

Looking in the installation folder, I can't find an executable file either (an .exe or a .cmd). Googling past questions shows that the node_modules folder (at least in past versions) should contain both an express folder (which I have) and a .bin folder, which contains express.cmd. I don't appear to have the .bin folder.

npm --version gives me 1.4.3. Express version looks to be 3.0.0

I've also tried installing it locally, and I've tried running npm cache clean and reinstalling. Neither method changes the situation: there's nothing executable in the node_modules folder.

Am I installing express incorrectly? If so, why does it not include an executable file?

user3523091

I ran into the same problem on Windows 8.1. The express.cmd is not created, but I found the text file:

C:\Users\you\AppData\Roaming\npm\node_modules\express\Readme.md

It suggests to run this:

npm install -g express-generator@3

Which will download more stuff.

After that you can use express on the windows command prompt. It will be in your path ( C:\Users\you\AppData\Roaming\npm)

Edit:

express-generator@3 is now updated to express-generator@4, so use this instead,

npm install -g express-generator@4

The answer isn't complete, because the modules are installed in C:\Users\you\AppData\Roaming\npm directory as stated above, and you cannot always access any module without, 1) linking it to your current project or 2) explicityly defining the NODE_PATH system variable pointing your node to the right place in the system.

First method,

After installing the module (express in our case), you can link it to your current project by going to your current project directory using cmd and executing below command,

npm link express

You will get a message like this if it is successfully linked,

D:\Project\node_modules\express -> C:\Users\Sufiyan\AppData\Roaming\npm\node_modules\express

(you cannot link directories without running cmd with Administrator privileges)

The second option is to create or update NODE_PATH system variable pointing your node to the right place in the system. Read this for details.

Also read this official Node.js documentation regarding the issue,

http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

NPM - Error: Cannot find module '../'

From Dev

Error "Cannot find module 'npmlog'" after "npm update -g"

From Dev

cannot find module after npm install

From Dev

Getting "Error: Cannot find module 'esprima'" after updating Meteor to 1.0.2.1

From Dev

Error: cannot find module npm-shrinkwrap

From Dev

express error - cannot find module - static file

From Dev

Repeatedly Getting "Cannot find module" error

From Dev

npm install i18next-conv: Error: Cannot find module 'readable-stream'

From Dev

npm install i18next-conv: Error: Cannot find module 'readable-stream'

From Dev

cannot find module faker after npm install --save-dev

From Dev

module.js:327 Error: Cannot find module 'express'

From Dev

Error: Cannot find module './'

From Dev

Error: Cannot find module './'

From Dev

Error: Cannot find module 'npm-registry-client'

From Dev

Running "npm" returns "Error: Cannot find module 'inherits'"

From Dev

npm version shows Error: Cannot find module 'readable-stream'

From Dev

NPM Error: Cannot find module 'are-we-there-yet'

From Java

Node.js Error: Cannot find module express

From Dev

Error: Cannot find module 'html' with Node.JS and Express

From Dev

Node.js Express Error: Cannot find module

From Dev

'Cannot find module 'process-nextick-args' npm error after reinstalling node.js in Windows10

From Dev

express can 't find helper function module Error: Cannot find module './helpers/isPrime'?

From Dev

Error: Cannot find module './args'

From Dev

Error - Cannot find module 'config'

From Dev

Error: Cannot find module 'libxmljs'

From Dev

Error - Cannot find module 'broccoli'

From Dev

Error: Cannot find module './pulp'

From Dev

Error: Cannot find module 'ms'

From Dev

Error: Cannot find module 'mongodb'

Related Related

  1. 1

    NPM - Error: Cannot find module '../'

  2. 2

    Error "Cannot find module 'npmlog'" after "npm update -g"

  3. 3

    cannot find module after npm install

  4. 4

    Getting "Error: Cannot find module 'esprima'" after updating Meteor to 1.0.2.1

  5. 5

    Error: cannot find module npm-shrinkwrap

  6. 6

    express error - cannot find module - static file

  7. 7

    Repeatedly Getting "Cannot find module" error

  8. 8

    npm install i18next-conv: Error: Cannot find module 'readable-stream'

  9. 9

    npm install i18next-conv: Error: Cannot find module 'readable-stream'

  10. 10

    cannot find module faker after npm install --save-dev

  11. 11

    module.js:327 Error: Cannot find module 'express'

  12. 12

    Error: Cannot find module './'

  13. 13

    Error: Cannot find module './'

  14. 14

    Error: Cannot find module 'npm-registry-client'

  15. 15

    Running "npm" returns "Error: Cannot find module 'inherits'"

  16. 16

    npm version shows Error: Cannot find module 'readable-stream'

  17. 17

    NPM Error: Cannot find module 'are-we-there-yet'

  18. 18

    Node.js Error: Cannot find module express

  19. 19

    Error: Cannot find module 'html' with Node.JS and Express

  20. 20

    Node.js Express Error: Cannot find module

  21. 21

    'Cannot find module 'process-nextick-args' npm error after reinstalling node.js in Windows10

  22. 22

    express can 't find helper function module Error: Cannot find module './helpers/isPrime'?

  23. 23

    Error: Cannot find module './args'

  24. 24

    Error - Cannot find module 'config'

  25. 25

    Error: Cannot find module 'libxmljs'

  26. 26

    Error - Cannot find module 'broccoli'

  27. 27

    Error: Cannot find module './pulp'

  28. 28

    Error: Cannot find module 'ms'

  29. 29

    Error: Cannot find module 'mongodb'

HotTag

Archive