I. Environment configuration
Nodejs download and installation
(1) Create a directory
First go to the usr directory and create a tools folder CD /usr && mkdir tools && CD tools
(2) Download the NodeJS package
Download wget nodejs.org/dist/v12.19 using the wget command…
(3) Decompress installation
Xz tar -xvf node-v12.19.0-linux-x64.tar After decompressing xz -d node-v12.19.0-linux-x64.tar, enter ls. Then change the folder name to nodejs: mv node-v12.19.0-linux-x64 nodejs
(4) Modify the configuration file
Configure environment variables so that the node command can be used globally
Go to the etc directory, edit the profile file and add the following code at the end of the file:
export NODE_HOME=/usr/tools/nodejs
export PATH=$NODE_HOME/bin:$PATH
export NODE_PATH=$NODE_HOME/lib/node_modules:$PATH
Copy the code
Go back to the/directory and run source /etc/profile
(5) The configuration is successful
Enter node -v and NPM -v anywhere
(6) Use Taobao mirror
1. Configure by running commands
NPM config set registry registry.npm.taobao.org Verify NPM config get registry If registry.npm.taobao.org is returned, the image is successfully configured. 2. Install by using CNPM
CNPM NPM install -g CNPM — registrar =registry.npm.taobao.org Run the CNPM install XXX command
The use of pm2
NPM install -g pm2 install -g pm2 install -g pm2 install -g pm2 install -g pm2 install -g pm2
- Start the process/apply pm2 start bin/ WWW or pm2 start app.js
- Pm2 start app.js –name wb123
- Add process/application watch pm2 start bin/ WWW –watch
- Stop WWW
- End All processes or applications pM2 stop all
- Delete process/apply pm2 delete WWW
- Delete all processes or apply pm2 delete all
- Pm2 list lists all processes/applications
- Pm2 describe WWW Describe a process/application
- View the resource consumption of processes and applications. Pm2 monit
- View PM2 logs
- To view the logs of a process/application, use pm2 logs WWW
- Restart the process or apply the pm2 restart WWW
- Restart all processes or apply pm2 restart all
Pm2 start bin/ WWW or pm2 start app.js/pm2 start bin/ WWW/pm2 start app.js/pm2 start bin/ WWW/pm2 start app.js
Netstat -ntlp Checks whether the running port is the port of the serviceCopy the code
If there is no ps -ef|grep pm2
Then kill 10922 to restartIf you still can’t change package.json to this and start with NPM startStill can’t if you want to configure ali cloud security group