Node.js : NPM Install Fails

标签 node.js ubuntu npm

如果我运行,我会收到此错误

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 npm@1.0.18 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)

实际上它做了一些事情,你可以看到它在最后写了它起作用了什么是大谎言!

最佳答案

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

如果你真的需要,this page建议您可以以 root 身份运行它,这样可以:

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

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

关于Node.js : NPM Install Fails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6752873/

相关文章:

node.js - 平均堆栈 - 平均 init 抛出错误

mysql - 尝试将用户连接到本地 mysql 数据库时出现零错误

postgresql - 启动 postgresql 服务器时出错 - 蛇油键出错

php - Ubuntu Server 14.04 LAMP更改php目录

linux - APT 存储库中找到的软件包中的 "-dev"后缀是什么

npm - 为什么 package-lock.json 将完整性哈希从 sha1 更改为 sha512?

node.js - Linux 上的 Angular 2 QuickStart 无法正常工作

node.js - Azure 网站 node.js http 请求失败

javascript - Shelljs:如何取消异步进程?

javascript - 如何使用 typescript 和 webpack 创建单页 Web 应用程序?