Node.js: Express doesn't work?

I installed express and it worked perfectly:

... npm http 200 https://registry.npmjs.org/send/-/send-0.1.4.tgz npm http GET https://registry.npmjs.org/fresh/0.2.0 npm http GET https://registry.npmjs.org/range-parser/0.0.4 npm http 304 https://registry.npmjs.org/fresh/0.2.0 npm http GET https://registry.npmjs.org/fresh/-/fresh-0.2.0.tgz npm http 304 https://registry.npmjs.org/range-parser/0.0.4 npm http GET https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz npm http 200 https://registry.npmjs.org/fresh/-/fresh-0.2.0.tgz npm http 200 https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz express@4.0.0 /usr/local/lib/node_modules/express β”œβ”€β”€ methods@0.1.0 β”œβ”€β”€ parseurl@1.0.1 β”œβ”€β”€ merge-descriptors@0.0.2 β”œβ”€β”€ utils-merge@1.0.0 β”œβ”€β”€ 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 ) β”œβ”€β”€ accepts@1.0.0 ( mime@1.2.11 , negotiator@0.3.0 ) └── serve-static@1.0.1 ( send@0.1.4 ) 

But then I do:

 express testapp -bash: express: command not found 

It is as if not installed. What's up with that?

Just FYI, do I have OSX, if that matters?

+7
express
source share
2 answers

The new version of Express (4.0) itself does not have a bin folder. You must install express-generator in order to get the settings.

Express 4.0 has made significant changes. In particular, the transfer of intermediaries and assistants to external modules.

If you need to start and run something right away, you need to install Express 3, and then find out how to start Express 4 when you have more time.

First make sure you have ./node_modules/.bin in your $ PATH. Then...

 npm install " express@3.x " express 

Or, if you have time to learn the differences in Express 4, you can get up and running by installing express-generator .

 npm install express-generator express 

IMPORTANT : make sure you have ./node_modules/.bin in the $ PATH shell variable. Executable files in Node modules are linked in the ./node_modules/.bin directory. Having in your path makes it easy to run these executable files without entering the entire path and without adding them around the world. Adding them all over the world is a bad idea if you are working with multiple projects and need to maintain backward compatibility with older projects.

TIP . You can find a list of Express intermediaries and helpers on Github .

+22
source share

This is how I got my express app to work. I ran first

 npm install -g express-generator 

Then I created my application with

 express app_name 

Where app_name is obviously the name of your application.

Then I installed the dependencies.

 cd app_name && npm install 

Then, to run the application, I did

 DEBUG=app_name ./bin/www 

Queries were generated by the system, and you can copy and paste them. Then you will visit

 http://localhost:3000/ 

Here is my application running locally

enter image description here

+5
source share

All Articles