-bash:express:在使用NPM安装express和express-generator后找不到命令

时间:2014-10-21 14:32:28

标签: node.js bash express npm

我已经安装了NodeJS和NPM的服务器。 然后使用NPM安装Express的过程:

$ npm install express -g

回答:

root@server ~ $ npm install express -g
npm http GET https://registry.npmjs.org/express
npm http 200 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/depd/0.4.5
npm http GET https://registry.npmjs.org/escape-html/1.0.1
npm http GET https://registry.npmjs.org/parseurl
npm http GET https://registry.npmjs.org/on-finished
npm http GET https://registry.npmjs.org/methods/1.1.0
npm http GET https://registry.npmjs.org/path-to-regexp/0.1.3
npm http GET https://registry.npmjs.org/fresh/0.2.4
npm http GET https://registry.npmjs.org/media-typer/0.3.0
npm http GET https://registry.npmjs.org/proxy-addr
npm http GET https://registry.npmjs.org/range-parser
npm http GET https://registry.npmjs.org/qs/2.2.4
npm http GET https://registry.npmjs.org/serve-static
npm http GET https://registry.npmjs.org/send/0.9.3
npm http GET https://registry.npmjs.org/type-is
npm http GET https://registry.npmjs.org/vary
npm http GET https://registry.npmjs.org/cookie/0.1.2
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/on-finished
npm http 304 https://registry.npmjs.org/escape-html/1.0.1
npm http GET https://registry.npmjs.org/merge-descriptors/0.0.2
npm http GET https://registry.npmjs.org/utils-merge/1.0.0
npm http GET https://registry.npmjs.org/finalhandler/0.2.0
npm http GET https://registry.npmjs.org/accepts
npm http GET https://registry.npmjs.org/etag
npm http 304 https://registry.npmjs.org/methods/1.1.0
npm http 304 https://registry.npmjs.org/depd/0.4.5
npm http 304 https://registry.npmjs.org/range-parser
npm http GET https://registry.npmjs.org/cookie-signature/1.0.5
npm http 304 https://registry.npmjs.org/proxy-addr
npm http 304 https://registry.npmjs.org/serve-static
npm http 304 https://registry.npmjs.org/fresh/0.2.4
npm http 304 https://registry.npmjs.org/type-is
npm http 304 https://registry.npmjs.org/media-typer/0.3.0
npm http 304 https://registry.npmjs.org/send/0.9.3
npm http 304 https://registry.npmjs.org/qs/2.2.4
npm http 304 https://registry.npmjs.org/vary
npm http 304 https://registry.npmjs.org/merge-descriptors/0.0.2
npm http 304 https://registry.npmjs.org/cookie/0.1.2
npm http 304 https://registry.npmjs.org/utils-merge/1.0.0
npm http 304 https://registry.npmjs.org/finalhandler/0.2.0
npm http 304 https://registry.npmjs.org/accepts
npm http 304 https://registry.npmjs.org/etag
npm http 304 https://registry.npmjs.org/cookie-signature/1.0.5
npm http 304 https://registry.npmjs.org/parseurl
npm http 304 https://registry.npmjs.org/path-to-regexp/0.1.3
npm http GET https://registry.npmjs.org/ee-first/1.0.5
npm http GET https://registry.npmjs.org/mime-types
npm http GET https://registry.npmjs.org/crc/3.0.0
npm http GET https://registry.npmjs.org/negotiator/0.4.9
npm http GET https://registry.npmjs.org/forwarded
npm http GET https://registry.npmjs.org/ipaddr.js/0.1.3
npm http GET https://registry.npmjs.org/ms/0.6.2
npm http GET https://registry.npmjs.org/destroy/1.0.3
npm http GET https://registry.npmjs.org/mime/1.2.11
npm http 304 https://registry.npmjs.org/mime-types
npm http 304 https://registry.npmjs.org/forwarded
npm http 304 https://registry.npmjs.org/negotiator/0.4.9
npm http 304 https://registry.npmjs.org/ipaddr.js/0.1.3
npm http 304 https://registry.npmjs.org/crc/3.0.0
npm http 304 https://registry.npmjs.org/ee-first/1.0.5
npm http 304 https://registry.npmjs.org/ms/0.6.2
npm http 304 https://registry.npmjs.org/mime/1.2.11
npm http 304 https://registry.npmjs.org/destroy/1.0.3
npm http GET https://registry.npmjs.org/mime-db
npm http 304 https://registry.npmjs.org/mime-db
express@4.9.8 /var/www/site/npm/lib/node_modules/express
├── merge-descriptors@0.0.2
├── utils-merge@1.0.0
├── cookie@0.1.2
├── fresh@0.2.4
├── escape-html@1.0.1
├── range-parser@1.0.2
├── cookie-signature@1.0.5
├── finalhandler@0.2.0
├── vary@1.0.0
├── media-typer@0.3.0
├── methods@1.1.0
├── parseurl@1.3.0
├── serve-static@1.6.4
├── path-to-regexp@0.1.3
├── depd@0.4.5
├── qs@2.2.4
├── debug@2.0.0 (ms@0.6.2)
├── on-finished@2.1.0 (ee-first@1.0.5)
├── proxy-addr@1.0.3 (forwarded@0.1.0, ipaddr.js@0.1.3)
├── etag@1.4.0 (crc@3.0.0)
├── send@0.9.3 (destroy@1.0.3, ms@0.6.2, mime@1.2.11)
├── accepts@1.1.2 (negotiator@0.4.9, mime-types@2.0.2)
└── type-is@1.5.2 (mime-types@2.0.2)

以及

$ npm install express-generator -g

回答:

root@server ~ $ npm install express-generator -g
npm http GET https://registry.npmjs.org/express-generator
npm http 304 https://registry.npmjs.org/express-generator
npm http GET https://registry.npmjs.org/commander/1.3.2
npm http GET https://registry.npmjs.org/mkdirp/0.5.0
npm http 304 https://registry.npmjs.org/mkdirp/0.5.0
npm http 304 https://registry.npmjs.org/commander/1.3.2
npm http GET https://registry.npmjs.org/keypress
npm http GET https://registry.npmjs.org/minimist/0.0.8
npm http 200 https://registry.npmjs.org/minimist/0.0.8
npm http GET https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz
npm http 304 https://registry.npmjs.org/keypress
npm http 200 https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz
/var/www/site/npm/bin/express -> /var/www/site/npm/lib/node_modules/express-generator/bin/express
express-generator@4.9.0 /var/www/site/npm/lib/node_modules/express-generator
├── commander@1.3.2 (keypress@0.1.0)
└── mkdirp@0.5.0 (minimist@0.0.8)

所有人都很高兴,至少我没有错误。 现在问题出现在我想使用express:

$ express myapp

回答:

-bash: express: command not found

通常在安装了快速生成器时会出现此问题,并且安装已解决,但不是我=(。如果有人知道我能做什么,会感谢你。

NodeJS版本:v0.11.13-pre NPM版本:1.4.6

Ps:我作为根

运行的所有这些命令

Ps2:抱歉我的英文不好

1 个答案:

答案 0 :(得分:2)

安装express-generator,我们看到

/var/www/site/npm/bin/express -> /var/www/site/npm/lib/node_modules/express-generator/bin/express

/var/www/site/npm/bin添加到$ PATH