[Linux] Install nodejs and npm on Linux system

1. Use apt to install

If your Linux system has apt command, such as Ubuntu system, you can use apt to quickly install and uninstall

sudo apt update
sudo apt install nodejs
sudo apt install npm
node -v

Although it is very convenient to install nodejs through apt, the installed version is not the latest. If it does not meet your needs, please take a look at the following method

2. Download the installation package from the official website

Go to the official website of nodejs https://nodejs.org/en/download and download a Linux Binaries version suitable for your system. As for whether to choose X64 or arm, it depends on your CPU
insert image description here

For example, what I downloaded here is Linux Binaries (x64)

mkdir /usr/local/nodejs && cd /usr/local/nodejs
wget https://nodejs.org/dist/v18.16.0/node-v18.16.0-linux-x64.tar.xz
tar -xvf node-v18.16.0-linux-x64.tar.xz
cd node-v18.16.0-linux-x64
ln -s /usr/local/nodejs/node-v18.16.0-linux-x64/bin/node /usr/local/bin/node
ln -s /usr/local/nodejs/node-v18.16.0-linux-x64/bin/npm /usr/local/bin/npm

Guess you like

Origin blog.csdn.net/qq_39147299/article/details/131122156