3

我是node新手express

我确实在我的 ubuntu 13.10 机器上安装了节点和 npm。现在,我正在尝试express使用以下命令进行全局安装(我按照官方网站上的说明进行操作)

sudo npm install express -g

但是当我想做的时候

express --help

或者

express

它在外壳中没有任何回报

执行时打印以下日志sudo npm install express -g

npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/commander/0.6.1
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/mkdirp/0.3.4
npm http GET https://registry.npmjs.org/buffer-crc32/0.2.1
npm http GET https://registry.npmjs.org/cookie/0.1.0
npm http GET https://registry.npmjs.org/fresh/0.1.0
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/send/0.1.0
npm http GET https://registry.npmjs.org/cookie-signature/1.0.1
npm http GET https://registry.npmjs.org/connect/2.7.11
npm http GET https://registry.npmjs.org/methods/0.0.1
npm http 304 https://registry.npmjs.org/cookie/0.1.0
npm http 304 https://registry.npmjs.org/mkdirp/0.3.4
npm http 304 https://registry.npmjs.org/buffer-crc32/0.2.1
npm http 304 https://registry.npmjs.org/range-parser/0.0.4
npm http 304 https://registry.npmjs.org/commander/0.6.1
npm WARN package.json range-parser@0.0.4 No repository field.
npm http 304 https://registry.npmjs.org/fresh/0.1.0
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/send/0.1.0
npm http 304 https://registry.npmjs.org/cookie-signature/1.0.1
npm WARN package.json fresh@0.1.0 No repository field.
npm http 304 https://registry.npmjs.org/connect/2.7.11
npm WARN package.json send@0.1.0 No repository field.
npm WARN package.json cookie-signature@1.0.1 No repository field.
npm http 304 https://registry.npmjs.org/methods/0.0.1
npm WARN package.json methods@0.0.1 No repository field.
npm WARN package.json methods@0.0.1 No readme data.
npm http GET https://registry.npmjs.org/mime/1.2.6
npm http GET https://registry.npmjs.org/cookie/0.0.5
npm http GET https://registry.npmjs.org/send/0.1.1
npm http GET https://registry.npmjs.org/qs/0.6.5
npm http GET https://registry.npmjs.org/formidable/1.0.14
npm http GET https://registry.npmjs.org/bytes/0.2.0
npm http GET https://registry.npmjs.org/pause/0.0.1
npm http 304 https://registry.npmjs.org/mime/1.2.6
npm http 304 https://registry.npmjs.org/bytes/0.2.0
npm WARN package.json bytes@0.2.0 No repository field.
npm http 304 https://registry.npmjs.org/cookie/0.0.5
npm http 304 https://registry.npmjs.org/formidable/1.0.14
npm http 304 https://registry.npmjs.org/qs/0.6.5
npm http 304 https://registry.npmjs.org/send/0.1.1
npm http 304 https://registry.npmjs.org/pause/0.0.1
npm WARN package.json pause@0.0.1 No repository field.
npm http GET https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/mime
/usr/bin/express -> /usr/lib/node_modules/express/bin/express
npm WARN package.json github-url-from-git@1.1.1 No repository field.
npm WARN package.json assert-plus@0.1.2 No repository field.
npm WARN package.json ctype@0.5.2 No repository field.
express@3.2.6 /usr/lib/node_modules/express
├── methods@0.0.1
├── fresh@0.1.0
├── range-parser@0.0.4
├── cookie-signature@1.0.1
├── buffer-crc32@0.2.1
├── cookie@0.1.0
├── debug@0.7.2
├── commander@0.6.1
├── mkdirp@0.3.4
├── send@0.1.0 (mime@1.2.6)
└── connect@2.7.11 (pause@0.0.1, bytes@0.2.0, qs@0.6.5, cookie@0.0.5, formidable@1.0.14, send@0.1.1)

有什么我想念的吗?

更新

我正在使用nodejs版本v0.10.12

4

2 回答 2

12

你必须跑

npm install -g express-generator

这会下载更多的东西,之后 express 命令应该可以工作。

于 2014-06-07T03:37:17.697 回答
3

正如@Nirk 用户所引用的

一些发行版将二进制名称更改为 nodejs,但脚本通常依赖于 node(由于历史原因——在 nodejs 出现之前,node 是一个非常古老的工具

在文件的第一行中进行了以下手动更改/usr/lib/node_modules/express/bin/express

#!/usr/bin/env node

#!/usr/bin/env nodejs

现在它对我有用

@Nirk,非常感谢您的支持

于 2013-06-23T09:41:53.597 回答