在Debian下安装NodeJS

  • 12 (Bookworm)
  • 13 (Trixie)

Official website support: Page not updated.

1.node.js

v24/v22.x/20.x/18.x/16.x

  • v24.x
sudo apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
  • v22.x
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
  • v20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

install

sudo apt-get install -y nodejs

update

first remove:

sudo apt remove nodejs

and then, remove libnode72:

sudo dpkg --remove --force-remove-reinstreq libnode72:amd64

last install:

sudo apt-get install -y nodejs

2. yarn js

curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | sudo gpg --dearmor -o /usr/share/keyrings/pubkey-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/pubkey-archive-keyring.gpg] \
https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn

Ref