只需执行此命令!

只需执行此命令!

我正在尝试安装 nodejs 和 npm,但是失败了。这是我的终端:

sudo apt-get install nodejs npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.

该怎么办?我有点迷茫了 :(

答案1

只需执行此命令!

通过安装 Node.js

sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

检查版本:

$ npm -v
1.4.9
$ node -v
v0.10.28

欲了解更多信息请访问指导

答案2

听起来你已经安装了其中一个 nodejs PPA。我使用的那个 PPA 已npm作为软件包的一部分分发nodejs,因此不可能也没有必要同时安装这两个 PPA。

安装nodejs并查看是否可以运行npm

答案3

您应该遵循Node.js 指南

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

相关内容