[New]Node installation and configuration on linux-Ubuntu-22.04-LTS
- A log for simple Node installation on the new server.
- with yarn and pm2
Step 1
- download the binary of the latest LTS version for the server from nodejs.org
I chose this version - 22.11.0(LTS)
Step 2
- secondly we unzip the
.tar.xz
and mv it to/usr/local/
or somewhere else.
Now execute the following command.
1 | tar -xvf ./node-v22.11.0-linux-x64.tar.xz |
- Important note: use you own
.tar.xz
file path and be more careful.
Step 3
- then we configure the
PATH
and also the npm registry.
To confirue the path, because I use root (which is not
recommend and very dangerous), so I just simply edit the
/etc/profile
, and you may edit the ~/.bashrc
similarly.
1 | nano /etc/profile |
And then we add the following lines to the bottom of the file
1 | export NODE_HOME=/usr/local/node-v22.11.0-linux-x64 |
- Note: you may use vi or vim instead. And the first line of these is the path to you node location
Now execute source
command to update
PATH
1 | source /etc/profile |
Now let's check you PATH
configuration, execute
the following command, and you are expected to see the correspond
output.
1 | node -v |
1 | npm -v |
Note: if you use different version of Node, the output will be different but you can check it on the nodejs.org
Now let's configure the registry is you are in China
1 | npm config set registry https://registry.npmmirror.com |
Step 4
- eventually we install yarn and pm2
Execute the following command
1 | npm install -g yarn |
To check the installation of pm2, use the command
pm2 -v
, and you are supposed to see something like
that
1 | root@hostname:~# pm2 -v |