Ubuntu / 安装 NodeJS 和 npm

use*_*829 12 javascript nodejs npm

我正在尝试安装 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.
Run Code Online (Sandbox Code Playgroud)

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

Ant*_*sev 14

只需执行此命令!

通过安装 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
Run Code Online (Sandbox Code Playgroud)

检查版本:

$ npm -v
1.4.9
$ node -v
v0.10.28
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请访问本指南

  • chris-lea 不再是理想的 ppa。https://github.com/nodesource/distributions#debinstall (2认同)

Oli*_*Oli 4

听起来您已经安装了 Nodejs PPA 之一。我使用的一个已npm作为软件包的一部分分发nodejs,不可能也没有必要安装两者。

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