E: Unable to locate package npm

2019-01-22 17:38发布

When i try to install npm with sudo apt-get install npm, i get following error:

E: Unable to locate package npm

Why can't apt find npm? Im using Debian 9 and already sudo apt-get install nodejs.

7条回答
老娘就宠你
2楼-- · 2019-01-22 18:32

From the official Node.js documentation:

A Node.js package is also available in the official repo for Debian Sid (unstable), Jessie (testing) and Wheezy (wheezy-backports) as "nodejs". It only installs a nodejs binary.

So, if you only type sudo apt-get install nodejs , it does not install other goodies such as npm.

You need to type:

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

Optional: install build tools

To compile and install native addons from npm you may also need to install build tools:

sudo apt-get install -y build-essential

More info: Docs

查看更多
登录 后发表回答