Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Express' is not recognized command (windows)

Okay I am running node on windows (7). Using npm I just installed modules to d:\ directory. Therefore my files structure looks like the following:

D:\   -myproject      -node_modules         -.bin         -express 

However, when I am in this 'myproject' directory, I can't seem to run 'express' for example:

D:\myproject\express site 'express' is not recognized as an internal or external command, operable program or batch file. 

Am I doing anything wrong?

like image 421
pewpewlasers Avatar asked Nov 25 '12 17:11

pewpewlasers


2 Answers

Try:

npm install -g express-generator@3 

That solved problem for me.

Edit: for version 4

npm install express-generator -g 

Description: express is the package for dependency of express js. express-generator is the package for enabeling express command and create a sample project, etc. Assuming that this is kept separate for the decoupling of project dependency with cli tool of express.

Another SO ref: https://stackoverflow.com/a/41311733/1666582

like image 74
Mladen Rakonjac Avatar answered Sep 20 '22 20:09

Mladen Rakonjac


My guess is that you didn't install Express globally. You can install express globally (and therefore available in your PATH) with the following command (see http://expressjs.com/guide.html) :

npm install -g express 

The way you install it is available only in the folder that you installed it and there is nothing wrong with that approach. There is very little advantage of having it available globally.

If express is not in your PATH you can run it by entering the full path to it:

\myproject\node_modules\.bin\express.cmd 
like image 45
Hector Correa Avatar answered Sep 17 '22 20:09

Hector Correa