0

I'm trying to install grunt.js. As the official docs says, I should run

npm install -g grunt-cli

as root (I'm using ubuntu linux). I'm trying - and I get the following error:

$ 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

Can someone please explain:

[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?
4

1 回答 1

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 install 工作得很好,没有任何抱怨。

于 2013-05-07T19:00:38.057 回答