For some reason after installing Express globally on my machine with npm install -g express if I cd into a directory and try to run express I get the following error:

express: command not found. 

Even if I run it with sudo I still get the same output. I've tried multiple different solutions to this problem and nothing has worked. I had installed node via homebrew which some threads on Stack Overflow indicated might have been a problem so I completely uninstalled node and reinstalled via the installer on nodejs.org (I'm now running v0.10.26) and the problem still persists.

If I go into my /usr/local/lib/node_modules Express is in there but within /usr/local/bin there is nothing regarding Express. I'm not sure if that's a problem or not but considering there are binaries for other globally installed node packages in that directory I'm thinking there may be something wrong there.

This is the exact output I get when I install:

npm http GET npm http 304 npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http GET npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http 304 npm http GET npm http GET npm http GET npm http GET npm http 304 npm http 304 npm http 304 npm http GET npm http GET npm http 304 npm http 304 npm http 304 express@4.0.0 /usr/local/lib/node_modules/express ├── methods@0.1.0 ├── parseurl@1.0.1 ├── utils-merge@1.0.0 ├── merge-descriptors@0.0.2 ├── escape-html@1.0.1 ├── debug@0.8.0 ├── cookie-signature@1.0.3 ├── range-parser@1.0.0 ├── fresh@0.2.2 ├── qs@0.6.6 ├── buffer-crc32@0.2.1 ├── cookie@0.1.0 ├── path-to-regexp@0.1.2 ├── type-is@1.0.0 (mime@1.2.11) ├── send@0.2.0 (mime@1.2.11) ├── serve-static@1.0.1 (send@0.1.4) └── accepts@1.0.0 (negotiator@0.3.0, mime@1.2.11) 

4 Answers

With the release of Express 4.0.0 it looks like you need to do sudo npm install -g express-generator.

7

You need to run:

npm install -gd express-generator 

The original express with cli, now the cli split into separate express-generator package. Originally generated by the project is running express node app.js, because httpserver relevant code in app.js, and now this part of the code to the project directory bin/www below, app.js retain only achieve app logic code, you need to run the bin/www. Just a very simple application and refinement package dependency version changes.

I was having this challenge for a number of days. After deep search, I learned that one has to read every available resource especially from the parent source [in this case EXPRESSJS.COM]. Here is a quick fix.

Beginning with version 4.0+ you don't necessarily need to install express-generator if you are running Node 8.2+. Simply run

npx express-generator 

The express-generator will run just the way it runs when you run:express

For more details see Getting Started

Happy reading and research hours.

I have been recently trying to install express-generator , however it would give out ,

$ zsh : command not found : express 

It was after i did

$ sudo npm install -g express $ sudo npm install -g express-generator 

But then , i saw the console log of the npm install commnand

/usr/local/Cellar/node/13.1.0/bin/express -> /usr/local/Cellar/node/13.1.0/lib/node_modules/express-generator/bin/express-cli.js 

which gave a hint that the executable express is in the bin folder.

So the solution is : Open up ~/.zshrc or ~/.bashrc and export the path as follows:

export PATH=/usr/local/Cellar/node/13.1.0/bin:$PATH 

It works now.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy