安装gruntjs时出错(node.js / npm包)

时间:2013-05-07 18:38:31

标签: node.js npm gruntjs

我正在尝试安装grunt.js。正如official docs所说,我应该运行

npm install -g grunt-cli

以root身份(我正在使用ubuntu linux)。我正在尝试 - 我收到以下错误:

$ sudo npm install -g grunt-cli
npm ERR! sudon't! 
npm ERR! sudon't! Running npm as root is not recommended!
npm ERR! sudon't! Seriously, don't do this!
npm ERR! sudon't!
npm ERR! couldn't read package.json in .
npm ERR! Error installing .
npm ERR! Error: ENOENT, No such file or directory 'package.json'
npm ERR! Report this *entire* log at <http://github.com/isaacs/npm/issues>
npm ERR! or email it to <npm-@googlegroups.com>
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok

有人可以解释一下:

[1] why npm says `sudon't` and grunt docs says `do sudo`? And what is it all about?
[2] I want to install the grunt as a tool. Why does the message complains about missing package.json which is project-dependent (and I don't want to run grunt on any project, I want to install it globally first)?
[3] what can I do to make it install successfully?

1 个答案:

答案 0 :(得分:0)

解决方案非常棘手......我正在使用ubuntu oneiric ocelot,一周前仍然维护(它不是那么老)。我通过默认的ubuntu软件包安装了node.js,结果证明是问题 - 我安装了0.4.9版本,这似乎是旧的,奇怪的和奇怪的(之前我没有使用node.js的经验)。我删除了它并按照https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager的说明添加了远程包存储库并从那里安装了node.js。现在我有一个闪亮的0.10.5与sudo npm安装工作完全正常,没有任何抱怨。