【问题标题】:"sudo npm install -g grunt-cli" gives me an error“sudo npm install -g grunt-cli”给我一个错误
【发布时间】:2013-09-15 05:26:57
【问题描述】:

尝试在 linux 12.04(带有镜像包源)上安装 gruntjs 时出现错误

这是错误:

 sudo npm install -g grunt-cli

npm ERR! Error: ENOENT, open '/home/havetl/.npm/d63f3d0b-grunt-cli.lock'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.5.0-23-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "grunt-cli"
npm ERR! cwd /home/havetl
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! path /home/havetl/.npm/d63f3d0b-grunt-cli.lock
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! Error: EACCES, open 'npm-debug.log'
npm ERR!  { [Error: EACCES, open 'npm-debug.log'] errno: 3, code: 'EACCES', path: 'npm-debug.log' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.5.0-23-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "grunt-cli"
npm ERR! cwd /home/havetl
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! path npm-debug.log
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open 'npm-debug.log'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/havetl/npm-debug.log
npm ERR! not ok code 0

感谢您的任何想法!

【问题讨论】:

    标签: node.js npm gruntjs


    【解决方案1】:

    这个博客对我有用:

    http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/

    错误是因为在 ubuntu v12 中,一些依赖项不适用于最新版本的 Node。

    【讨论】:

      【解决方案2】:

      根据 npm 的维护者的说法,使用 sudo 安装软件包被认为是不好的做法,因为您允许该软件包完全控制您的系统,并且您不能也不应该信任这些具有 root 访问权限的软件包。出于这个确切原因,将 Debian 的长发布周期视为保护最终用户免受社区维护的软件包的极端示例。

      http://howtonode.org/introduction-to-npm

      您应该按照 Issaacs 的建议和 chown 您的 /usr/local 文件夹执行操作,以便拥有 RW 权限。

      【讨论】:

        【解决方案3】:

        我以前遇到过这个问题;有时对于全局包,您当前的工作目录必须是~/(但我不确定这是为什么!)。试试:

        cd ~/; sudo npm install -g grunt-cli
        

        【讨论】:

        • 对不起,它对我不起作用。事实上,我也在我的家庭目录中尝试过。
        • 这可能是权限问题。你是如何安装节点的? apt-get?此链接可能有用:hacksparrow.com/how-to-install-node-js-on-ubuntu-linux.html
        • 查看我的答案...这是将sudo 与包管理器一起使用的坏习惯。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-05-08
        • 2013-12-14
        • 1970-01-01
        • 2016-02-11
        • 2017-06-07
        • 2019-12-17
        • 1970-01-01
        相关资源
        最近更新 更多