当我尝试使用安装npm时sudo apt-get install npm
,出现以下错误:
E:无法找到软件包npm
为什么找不到npm?我正在使用Debian 9并且已经运行了
sudo apt-get install nodejs
Answers:
从官方的Node.js文档中:
在Debian Sid(不稳定),Jessie(测试)和Wheezy(wheezy-backports)的官方仓库中,也有一个Node.js软件包,称为“ nodejs”。它仅安装nodejs二进制文件。
因此,如果仅键入sudo apt-get install nodejs
,则不会安装其他东西,例如npm。
您需要输入:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
可选:安装构建工具
要从npm编译并安装本机加载项,您可能还需要安装构建工具:
sudo apt-get install -y build-essential
更多信息:文档
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
得到以下输出: + apt-get install -y lsb-release > /dev/null 2>&1
Error executing command, exiting
我在Debian 9.2上遇到了同样的问题,这就是我为克服它所做的。
安装
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get install -y nodejs
sudo apt-get install -y npm
检查安装的版本
node --version
npm --version
最初源自“如何在Debian 9 Stretch上安装Node.js LTS” http://linuxbsdos.com/2017/06/26/how-to-install-node-js-lts-on-debian-9-stretch/
apt install nodejs
呢?
curl -sL https://deb.nodesource.com/setup_lts.x | sudo bash -
最新的lts版本。
您的系统找不到npm软件包,因为您尚未将nodejs存储库添加到系统中。
尝试执行以下安装步骤:
将nodejs PPA存储库也添加到我们的系统和python软件属性中
sudo apt-get install curl python-software-properties
// sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt-get update
然后安装npm
sudo apt-get install nodejs
检查是否已安装npm和node并准备使用node.js
node -v
npm -v
如果有人无法安装Node.js,请尝试先删除npm,也许旧的安装已被破坏。
sudo apt-get remove nodejs
sudo apt-get remove npm
检查npm或节点文件夹是否仍然存在,如果找到它们则将其删除
which node
which npm
这样可以解决您的错误。在终端中运行这些命令。这些命令将添加旧版本。您可以稍后更新它们,也可以在此处逐一更改这些命令之前更改版本。
sudo apt-get install build-essential
wget http://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz
tar -xzf node-v0.8.16.tar.gz
cd node-v0.8.16/
./configure
make
sudo make install
对于Debian Stretch,nodejs
它不包含npm
,并且要作为单独的软件包安装,必须启用stretch-backports
。
echo 'deb http://deb.debian.org/debian stretch-backports main' |
sudo tee /etc/apt/sources.list.d/stretch-backports.list
apt-get update -y
apt-get -t stretch-backports install -y npm
在Buster中,这npm
是一个常规软件包,因此,向前看,它应该可以正常工作。但是我们中有些人仍然会在一段时间内被部分卡在弹力盒上。
在我的jenkins / jenkins中,docker sudo总是产生错误:
bash: sudo: command not found
我需要更新回购清单:
curl -sL https://deb.nodesource.com/setup_10.x | apt-get update
然后,
apt-get install nodejs
所有命令行结果如下:
root@76e6f92724d1:/# curl -sL https://deb.nodesource.com/setup_10.x | apt-get update
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:3 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:4 http://deb.debian.org/debian stretch Release [118 kB]
Get:5 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [520 kB]
Get:6 http://deb.debian.org/debian stretch-updates/main amd64 Packages [27.9 kB]
Get:8 http://deb.debian.org/debian stretch Release.gpg [2410 B]
Get:9 http://deb.debian.org/debian stretch/main amd64 Packages [7083 kB]
Get:7 https://packagecloud.io/github/git-lfs/debian stretch InRelease [23.2 kB]
Get:10 https://packagecloud.io/github/git-lfs/debian stretch/main amd64 Packages [4675 B]
Fetched 7965 kB in 20s (393 kB/s)
Reading package lists... Done
root@76e6f92724d1:/# apt-get install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libicu57 libuv1
The following NEW packages will be installed:
libicu57 libuv1 nodejs
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 11.2 MB of archives.
After this operation, 45.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian stretch/main amd64 libicu57 amd64 57.1-6+deb9u3 [7705 kB]
Get:2 http://deb.debian.org/debian stretch/main amd64 libuv1 amd64 1.9.1-3 [84.4 kB]
Get:3 http://deb.debian.org/debian stretch/main amd64 nodejs amd64 4.8.2~dfsg-1 [3440 kB]
Fetched 11.2 MB in 26s (418 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libicu57:amd64.
(Reading database ... 12488 files and directories currently installed.)
Preparing to unpack .../libicu57_57.1-6+deb9u3_amd64.deb ...
Unpacking libicu57:amd64 (57.1-6+deb9u3) ...
Selecting previously unselected package libuv1:amd64.
Preparing to unpack .../libuv1_1.9.1-3_amd64.deb ...
Unpacking libuv1:amd64 (1.9.1-3) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_4.8.2~dfsg-1_amd64.deb ...
Unpacking nodejs (4.8.2~dfsg-1) ...
Setting up libuv1:amd64 (1.9.1-3) ...
Setting up libicu57:amd64 (57.1-6+deb9u3) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Setting up nodejs (4.8.2~dfsg-1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
使用以下命令下载存储库密钥:
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt键添加-
然后设置存储库:
$ sudo sh -c“ echo deb https://deb.nodesource.com/node_8.x宇宙主\
/etc/apt/sources.list.d/nodesource.list“ $ sudo apt-get更新$ sudo apt-get install nodejs
我有一个类似的问题,这对我有用。
添加NodeSource包签名密钥
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt键添加-
添加所需的NodeSource存储库
版本= node_12.x
DISTRO =“ $(lsb_release -s -c)” echo“ deb https://deb.nodesource.com/ $ VERSION $ DISTRO main” | sudo tee /etc/apt/sources.list.d/nodesource.list echo“ deb-src https://deb.nodesource.com/ $ VERSION $ DISTRO main” | sudo tee -a /etc/apt/sources.list.d/nodesource.list
更新软件包列表并安装Node.js
sudo apt-get更新sudo apt-get安装nodejs