node.js - Path of the express -
why express command not found. here path express.
/usr/lib/node_modules/express
when install express, terminal shows path. used
npm install -g express-generator npm install -g express
but when run express, doesn't work. in directory, express globally right? why can't found. don't understand logic.
you need install express locally, rather globally.
http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation
in general, rule of thumb is:
- if you’re installing want use in program, using require('whatever'), install locally, @ root of project.
- if you’re installing want use in shell, on command line or something, install globally, binaries end in path environment variable.
based on this, want install express-generator
using -g
flag use command line tool, want install express
without flag it's module want require()
in application.
take @ installation guide:
http://expressjs.com/starter/generator.html
it says install express-generator
module global module use command line utility scaffold new applications.
once have scaffolded application using express myapp
command, have run npm install
in myapp
directory download rest of dependencies projects local ./node_modules
directory. reading contents of generated package.json
file.
lesson take away: don't install -g
flag unless modules instruction guide explicitly says so.
Comments
Post a Comment