Node.js:NPM 安装失败

发布于 2024-11-25 00:06:44 字数 1836 浏览 0 评论 0原文

运行,我会收到此错误

curl http://npmjs.org/install.sh | sh

如果我使用 sudo

    cirk@cirk-Parallels-Virtual-Platform:~$ curl http://npmjs.org/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3902  100  3902    0     0   6138      0 --:--:-- --:--:-- --:--:-- 12546
fetching: http://registry.npmjs.org/npm/-/npm-1.0.18.tgz
0.4.9
1.0.18
Skipping 0.x cruft clean
! [ -d .git ] || git submodule update --init --recursive
node cli.js cache clean
node cli.js rm npm -g -f --loglevel error
node cli.js install -g -f
npm ERR! error installing [email protected] Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm.js'
npm ERR! Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm.js'
npm ERR! 
npm ERR! Please use 'sudo' or log in as root to run this command.
npm ERR! 
npm ERR!     sudo npm "install" "-g" "-f"
npm ERR! 
npm ERR! or set the 'unsafe-perm' config var to true.
npm ERR! 
npm ERR!     npm config set unsafe-perm true
npm ERR! 
npm ERR! System Linux 2.6.38-10-generic
npm ERR! command "node" "/tmp/npm.1568/package/cli.js" "install" "-g" "-f"
npm ERR! cwd /tmp/npm.1568/package
npm ERR! node -v v0.4.9
npm ERR! npm -v 1.0.18
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /tmp/npm.1568/package/npm-debug.log
npm not ok
It worked

。我应该怎么办?我尝试了这些,但没有成功:

chown -R cirk /usr/lib/nodejs
// and also this
chown -R cirk /usr/lib/node_modules (node_modules is empty it tries to install NPM here or what)

实际上它做了一些事情,正如你所看到的,它在最后写道它起作用了这是一个弥天大谎!

I get this error if I run

curl http://npmjs.org/install.sh | sh

even with sudo.

    cirk@cirk-Parallels-Virtual-Platform:~$ curl http://npmjs.org/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3902  100  3902    0     0   6138      0 --:--:-- --:--:-- --:--:-- 12546
fetching: http://registry.npmjs.org/npm/-/npm-1.0.18.tgz
0.4.9
1.0.18
Skipping 0.x cruft clean
! [ -d .git ] || git submodule update --init --recursive
node cli.js cache clean
node cli.js rm npm -g -f --loglevel error
node cli.js install -g -f
npm ERR! error installing [email protected] Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm.js'
npm ERR! Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm.js'
npm ERR! 
npm ERR! Please use 'sudo' or log in as root to run this command.
npm ERR! 
npm ERR!     sudo npm "install" "-g" "-f"
npm ERR! 
npm ERR! or set the 'unsafe-perm' config var to true.
npm ERR! 
npm ERR!     npm config set unsafe-perm true
npm ERR! 
npm ERR! System Linux 2.6.38-10-generic
npm ERR! command "node" "/tmp/npm.1568/package/cli.js" "install" "-g" "-f"
npm ERR! cwd /tmp/npm.1568/package
npm ERR! node -v v0.4.9
npm ERR! npm -v 1.0.18
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /tmp/npm.1568/package/npm-debug.log
npm not ok
It worked

What should I do? I tried these with no success:

chown -R cirk /usr/lib/nodejs
// and also this
chown -R cirk /usr/lib/node_modules (node_modules is empty it tries to install NPM here or what)

actually it did something, as you can see it writes at the end It worked what is a big lie!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅忆流年 2024-12-02 00:06:44

为什么要在 /usr 中运行它?

如果您确实需要,此页面建议您可以以 root 身份运行它,这样就可以了:

curl https://www.npmjs.com/install.sh | sudo sh

但在运行之前,您最好确保它不会破坏您的系统。

Why are you running that in /usr?

If you really need to, this page suggests you may run that as root, so that would be:

curl https://www.npmjs.com/install.sh | sudo sh

But you better make sure it won't break your system, before running that.

陪你到最终 2024-12-02 00:06:44

我搞砸了 npm 安装的权限,并在重新安装时出现此错误。我用最粗暴的方式解决了这个问题:通过自由地 sudo rm -rf 处理任何给我带来麻烦的目录树,然后重新编译 node.js 并重新安装 npm。

如果其他方法都失败了,你可以回到原来的方法。

I screwed up the permissions on my npm installation, and had this error when reinstalling. I solved it in the crudest way: by liberally sudo rm -rfing any directory tree that gave me trouble, then recompiling node.js and reinstalling npm.

If all else fails, you could fall back to that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文