无法通过 nodesource/distributions 在 ubuntu22 上安装 nodejs16/18/20?
参考:https://github.com/nodesource/distributions
docker pull ubuntu:22.04
docker run --rm -it ubuntu:22.04 bash
apt-get update
apt-get install -y ca-certificates curl gnupg
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=16; echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
apt-get update
apt-get install nodejs npm -y
报错
137 added, 0 removed; done.
Setting up gpg-wks-server (2.2.27-3ubuntu2.1) ...
Setting up libcurl4:amd64 (7.81.0-1ubuntu1.13) ...
Setting up curl (7.81.0-1ubuntu1.13) ...
Setting up gpg-wks-client (2.2.27-3ubuntu2.1) ...
Setting up gnupg (2.2.27-3ubuntu2.1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Processing triggers for ca-certificates (20230311ubuntu0.22.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Get:3 https://deb.nodesource.com/node_16.x nodistro InRelease [12.1 kB]
Hit:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:5 https://deb.nodesource.com/node_16.x nodistro/main amd64 Packages [7253 B]
Hit:6 http://security.ubuntu.com/ubuntu jammy-security InRelease
Fetched 19.4 kB in 6s (3210 B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
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
npm : Depends: node-cacache but it is not going to be installed
Depends: node-gyp but it is not going to be installed
Depends: node-mkdirp but it is not going to be installed
Depends: node-nopt but it is not going to be installed
Depends: node-tar but it is not going to be installed
Depends: node-which but it is not going to be installed
Depends: nodejs:any (>= 10)
Recommends: git but it is not going to be installed
Recommends: node-tap but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
回复
1个回答
test
2024-06-26
nodejs这个包里面已经有npm了。
npm这个包,ubuntu默认的仓库里面默认就有,这个包和nodesource仓库里面冲突应该不算意外。
回复
适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容