Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Express command not working in terminal

I am kind of new to node.js. I installed node fine and it works. I can run the node command in the terminal as well as the node package manager command(npm). Working on a Mac by the way. So I installed express globally with the following command:

sudo npm install -g express 

After I was done installing it globally I installed it in a small folder where I am working on a project.

sudo install express 

That gave me a node_modules folder inside of my site folder. After I was done that I went to install stylus using the express command and I got the error that express is not a command.

express -c stylus 

Can anyone shed some light on this issue? I also tried to link the global express to the folder where I am working on the project using the following command:

sudo npm link express 

The terminal said that this command ran, but I still cannot run the express command.

like image 248
Max Baldwin Avatar asked Apr 09 '14 22:04

Max Baldwin


People also ask

Why is my node command not working?

Make sure the node path is added, if not added it. After doing this restart Visual Studio or open a fresh command prompt. From the command prompt type 'node -v' to echo the node version installed. You can also add the path to node or any other application directly on the command line.

Do I have to install Express every time?

every time I make a new project? Yes, install Express and other NPM components separately for each project. This way, you keep each project independent from the others and you can upgrade components in one without affecting all the others.


2 Answers

Thanks for asking questions on this one. I found that running express-generator instead of just express fixed the problem. The following code in the terminal worked.

sudo npm install -g express-generator 

Thanks again,

like image 93
Max Baldwin Avatar answered Sep 19 '22 19:09

Max Baldwin


If your express binary keeps doing nothing. Install node-legacy:

sudo apt-get install nodejs-legacy

like image 29
Quentin Rufin Avatar answered Sep 17 '22 19:09

Quentin Rufin