[英]Problems installing npm on Ubuntu 16.04
尝试使用简单的sudo apt-get install npm
install npm在Ubuntu 16.04上sudo apt-get install npm
,出现以下错误:
The following packages have unmet dependencies:
npm : Depends: nodejs but it is not going to be installed
Depends: node-abbrev (>= 1.0.4) but it is not going to be installed
Depends: node-ansi (>= 0.3.0-2) but it is not going to be installed
Depends: node-ansi-color-table but it is not going to be installed
Depends: node-archy but it is not going to be installed
Depends: node-block-stream but it is not going to be installed
Depends: node-fstream (>= 0.1.22) but it is not going to be installed
Depends: node-fstream-ignore but it is not going to be installed
Depends: node-github-url-from-git but it is not going to be installed
Depends: node-glob (>= 3.1.21) but it is not going to be installed
Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed
Depends: node-inherits but it is not going to be installed
Depends: node-ini (>= 1.1.0) but it is not going to be installed
Depends: node-lockfile but it is not going to be installed
Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed
Depends: node-minimatch (>= 0.2.11) but it is not going to be installed
Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed
Depends: node-gyp (>= 0.10.9) but it is not going to be installed
Depends: node-nopt (>= 3.0.1) but it is not going to be installed
Depends: node-npmlog but it is not going to be installed
Depends: node-once but it is not going to be installed
Depends: node-osenv but it is not going to be installed
Depends: node-read but it is not going to be installed
Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed
Depends: node-request (>= 2.25.0) but it is not going to be installed
Depends: node-retry but it is not going to be installed
Depends: node-rimraf (>= 2.2.2) but it is not going to be installed
Depends: node-semver (>= 2.1.0) but it is not going to be installed
Depends: node-sha but it is not going to be installed
Depends: node-slide but it is not going to be installed
Depends: node-tar (>= 0.1.18) but it is not going to be installed
Depends: node-underscore but it is not going to be installed
Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
我检查了是否安装了节点:
$ which nodejs
/usr/bin/nodejs
$ which node
/usr/bin/node
从这里我有点迷路。 有人知道从这里做什么吗?
我建议您重新安装Nodejs,因为
npm:依赖于:nodejs,但是不会被安装
错误中指出未安装nodejs(未正确安装)。
我建议您从https://nodejs.org/en/download/下载源代码 node-v6.9.1.tar.gz
然后
tar -zxvf node-v6.9.1.tar.gz
cd node-v6.9.1
./configure
make
sudo make install
通过以上步骤, Nodejs和NPM将安装在您的计算机上。
您可以在命令提示符下使用node -v
和npm -v
验证安装。
最后,我通过安装nvm (将版本号调整为当前版本)解决了该问题:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
export NVM_DIR="$HOME/.nvm" # OR LOG OUT AND BACK IN AGAIN
然后,我使用nvm安装了最新版本的node,该节点也安装了npm。
nvm install node
我希望这可以帮助遇到相同问题的其他人。
请参阅节点包管理器已损坏
您可以执行以下操作
sudo apt-get remove nodejs npm ## remove existing nodejs and npm packages
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
这适用于我的Ubuntu 16.04.2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.