Log in to Kim account
update
sudo apt-get update
Copy the code
Installation of Basic Tools
Sudo apt-get install vim openssl build-essential libssl-dev wget curl gitCopy the code
NVM installation
The curl - o - https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bashCopy the code
To solve the problem Failed to connect to raw.githubusercontent.com
To resolve the problem, change the host of the host. First query by IP query website raw.githubusercontent.com the IP address of the corresponding, found out is 199.232.92.133, then edit the hosts file, sudo vi/etc/hosts a record increase
199.232.92.133 raw.githubusercontent.com
Copy the code
Exit the editor then perform a curl – o – https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash this time started to download and install NVM, is still very slow, It will take a while.
Kim @ - 0-12 - ubuntu VM: ~ $curl - o - https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash % % of Total Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- - : -- : -- -- -- : 0 0 0 0 0 0 0 0 - : -- : -- 0:00:01 -- : - : - 0 0 0 0 0 0 0 0 - : -- : -- 0:00:02 -- : - : - 100 9135 100 9135 0 0 3194 0 0:00:02 0:00:02 --:--:-- 3195 => Downloading nvm from git to '/home/kim/.nvm' => Cloning into '/home/kim/.nvm'... remote: Enumerating objects: 23, done. remote: Counting objects: 100% (23/23), done. remote: Compressing objects: 100% (21/21), done. Identifiers objects: 58% (4724/8144), 1.99 MiB | KiB / 10.00Copy the code
The installation is complete
Checking connectivity... Done. * (HEAD detached at V0.31.4) master => Appending source string to /home/kim/. Bashrc bash: line 293: / nfm. sh: No such file or directory => Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="/home/kim/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvCopy the code
As prompted, we can restart Terminal or execute the following commands to use NVM immediately
export NVM_DIR="/home/kim/.nvm"
. "$NVM_DIR/nvm.sh"
Copy the code
Take a look at the NVM version
kim@VM-0-12-ubuntu:~$NVM --version 0.31.4 kim@VM-0-12-ubuntu:~$NVM ls N/A node -> stable (-> N/A) (default) iojs -> N/A (default)Copy the code
Install NVM from Git
If the above instructions take too long to install, you can take another approach and download the NVM source code from Git and install it
- Run the following command to download the NVM source code and check the latest version
git clone https://github.com/cnpm/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
Copy the code
- Run the following command to configure the NVM environment variables.
echo ". ~/.nvm/nvm.sh" >> /etc/profile
Copy the code
- Run the following command to read the environment variables.
source /etc/profile
Copy the code
- Run the following command to view all versions of Node.js and the required versions
NVM list-remote NVM install v14.15.4Copy the code
Common instructions for NVM
# NVM install v14.15.4 # NVM install v14.15.4 # Check node and NPM versions node --version NPM --versionCopy the code
Yarn installation
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
sudo sh -c 'echo "deb https://dl.yarnpkg.com/debian/ stable main" >> /etc/apt/sources.list.d/yarn.list'
sudo apt update
sudo apt install yarn
Copy the code
Check the YARN version
Kim @ - 0-12 - ubuntu VM: 1.22.5 ~ $yarn - vCopy the code
Pm2 installation
# # NPM NPM install - registry=https://registry.npm.taobao.org - g pm2 NPM install pm2 # version pm2 view - - g versionCopy the code
If yarn is used, No command ‘pm2’ found is displayed
reference
Pm2 tutorial How To Set Up a Node.js Application for Production on Ubuntu 16.04