Ubuntu /安装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. 

该怎么办? 我有点失落:(

只需执行此命令!

通过package-manager安装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 

有关详细信息,请访问此指南

听起来你已经安装了一个nodejs PPA。 我使用的是将npm作为nodejs包的一部分进行分发,并且安装它们是不可能的,也是不必要的。

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

您应该遵循Node.js指南

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

您可以按照此链接在系统中设置npm。 该链接非常适合在系统中设置npm。