強制 apt-get 安裝更高版本的 nodejs

強制 apt-get 安裝更高版本的 nodejs

我使用的是 Debian 11,完全是最新的 ( apt-get update && apt-get upgrade && apt-get dist-upgrade)。我之前安裝了nodejs12.22 版本,因為這是 Debian 儲存庫中的版本,如下所示:

$ sudo apt-get install nodejs
$ node -v
v12.22.5

不過我想用 v14.18。我刪除了節點版本 12 的所有痕跡,如下所示:

$ sudo apt-get remove --purge nodejs

然後使用nodejs加入PPAhttps://github.com/nodesource/distributions:

$ curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup_14_lts.sh
$ sudo bash nodesource_setup_14_lts.sh

我可以看到它已在以下位置添加了新的 PPA /etc/apt/sources.list.d/

$ cat /etc/apt/sources.list.d/nodesource.list 
deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x bullseye main
deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x bullseye main
$ sudo apt-get update
Hit:1 http://httpredir.debian.org/debian bullseye InRelease
Hit:2 http://httpredir.debian.org/debian-security bullseye-security InRelease
Hit:3 http://httpredir.debian.org/debian bullseye-updates InRelease
Hit:4 https://deb.nodesource.com/node_14.x bullseye InRelease
Reading package lists... Done

但現在當我去安裝時nodejs它仍然使用版本 12 :(

$ sudo apt-get install nodejs --dry-run
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Inst nodejs (12.22.5~dfsg-2~11u1 Debian:11.1/stable, Debian-Security:11/stable-security [i386])
Conf nodejs (12.22.5~dfsg-2~11u1 Debian:11.1/stable, Debian-Security:11/stable-security [i386])

似乎沒有使用新的 PPA 來決定安裝apt-get的版本。nodejs如何在系統範圍內安裝 v14.18?

編輯

請注意,我使用的是 32 位元機器:

$ uname -m
i686

當我在另一台 64 位元電腦上執行上述過程時,它工作正常,並且從 PPA 安裝版本 14.18。

額外要求的資訊:

$ apt-cache policy nodejs
nodejs:
  Installed: (none)
  Candidate: 12.22.5~dfsg-2~11u1
  Version table:
     12.22.5~dfsg-2~11u1 500
        500 http://httpredir.debian.org/debian bullseye/main i386 Packages
        500 http://httpredir.debian.org/debian-security bullseye-security/main i386 Packages

答案1

i386 年版本已放棄。查看可用架構

NodeSource 將繼續維護以下架構,並可能在未來添加其他架構。

amd64 (64-bit)
armhf (ARM 32-bit hard-float, ARMv7 and up: arm-linux-gnueabihf)
arm64 (ARM 64-bit, ARMv8 and up: aarch64-linux-gnu)

您必須nodejs從 debian 儲存庫而不是節點儲存庫安裝。

相關內容