我试图在Ubuntu 12.10 (Quantal Quetzal)上安装Node.js,但终端显示关于丢失包的错误。我试过这样做:

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

但是当我来到最后一行sudo apt-get install nodejs npm显示这个错误:

Failed to install some packages. This may mean that
you requested an impossible situation or if you are using the distribution
distribution that some required packages have not yet been created or been
been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nodejs: Conflicts: npm
E: Failed to correct problems, you have held broken packages.

然后我卸载了ppa:chris-lea/node.js,我正在尝试第二种选择:

sudo apt-get install node.js
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm

同样的错误,终端说npm是最新版本,但它也显示了我在顶部显示的文本。我认为问题是ppa:chris-lea/node.js,但我不知道如何解决它。


当前回答

在最新版本的Node.js中,npm会自动与Node.js一起安装。当你在终端中输入node—version和npm—version时,你会看到什么?

你也可以使用npm本身来升级npm:

[sudo] npm install -g npm

其他回答

获取最新的Node.js

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

sudo apt-get install nodejs
node -v
npm -v

简单地按照这里给出的说明:

Example install: sudo apt-get install python-software-properties python g++ make sudo add-apt-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install nodejs It installs current stable Node on the current stable Ubuntu. Quantal (12.10) users may need to install the software-properties-common package for the add-apt-repository command to work: sudo apt-get install software-properties-common As of Node.js v0.10.0, the nodejs package from Chris Lea's repo includes both npm and nodejs-dev.

不要给sudo apt-get install nodejs npm。只需sudo apt-get install nodejs。

Sudo apt安装nodejs 必须安装NPM curl - sl https://deb.nodesource.com/setup_14.x | sudo - e bash - . Sudo apt-get install -y nodejs

在最新版本的Node.js中,npm会自动与Node.js一起安装。当你在终端中输入node—version和npm—version时,你会看到什么?

你也可以使用npm本身来升级npm:

[sudo] npm install -g npm

很简单:

sudo apt install nodejs

然后输入:

nodejs

使用它。