I installed express, and it worked just fine:
...
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's as if express is not installed. What's up with that?
Just FYI, i have OSX if that makes any difference?
The new version of Express (4.0) does not itself have a bin
folder. You have to install express-generator
to get the setup functionality.
Express 4.0 made significant changes. Specifically, moving middlewares and helpers into external modules.
If you need to get something up and running right away, you should install Express 3 and then learn how to get Express 4 running 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 then you can get up and running by installing express-generator
.
npm install express-generator
express
IMPORTANT : make sure you have ./node_modules/.bin
in your shell $PATH variable. Executable files in Node modules are linked in the ./node_modules/.bin
directory. Having that in your path makes it easy to run those executables without typing the whole path and without adding them globally. Adding them globally is a bad idea if you work with multiple projects and need to maintain backwards compatibility with old projects.
TIP : You can find the list of Express middlewares and helpers on Github .
Here is how I got my express app to work. I first ran
npm install -g express-generator
Then I created my app with
express app_name
Where app_name
is obviously the name of your app.
Then I installed the dependancies.
cd app_name && npm install
Then to run the app I did
DEBUG=app_name ./bin/www
The prompts were generated by the system and you can copy and paste them. Then you visit
http://localhost:3000/
Here is my app working locally
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.