首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ubuntu 16.04安装npm的问题

Ubuntu 16.04安装npm的问题
EN

Stack Overflow用户
提问于 2016-12-01 09:50:53
回答 3查看 2K关注 0票数 0

当尝试使用简单的sudo apt-get install npm在Ubuntu16.04上安装npm时,我得到以下错误:

代码语言:javascript
复制
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.

我检查了节点是否安装:

代码语言:javascript
复制
$ which nodejs
/usr/bin/nodejs
$ which node
/usr/bin/node

从现在起我有点迷路了。有人知道从这里该怎么做吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-12-01 12:19:47

最后,我用安装nvm (根据当前版本调整版本号)解决了这个问题:

代码语言:javascript
复制
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来安装节点的最新版本,该节点也安装了npm。

代码语言:javascript
复制
nvm install node

我希望这能帮助其他人解决同样的问题。

票数 0
EN

Stack Overflow用户

发布于 2016-12-01 11:13:04

我建议您重新安装Nodejs

npm :依赖: nodejs,但是它不会被安装

在错误中,说明nodejs没有安装(没有正确安装)。

我建议您从node-v6.9.1.tar.gz下载源代码

然后

代码语言:javascript
复制
tar -zxvf  node-v6.9.1.tar.gz

cd node-v6.9.1

./configure

make

sudo make install

NodejsNPM将按照上述步骤安装在您的计算机上。

您可以在命令提示符上使用node -vnpm -v验证安装。

票数 0
EN

Stack Overflow用户

发布于 2017-05-19 07:01:28

请参阅节点包管理器损坏

您可以执行以下操作

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40907340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档