centos安装nodejs并配置生产环境,基于pm2

时间:2023-03-09 15:55:06
centos安装nodejs并配置生产环境,基于pm2

安装nodejs和yarn的命令:

curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
//参见:https://github.com/nodesource/distributions
sudo yum install yarn

安装pm2

yarn global add pm2

配置package.json
后台静默启动的快捷命令:

"scripts": {
"start": "pm2 start index.js --watch --name redredstar",
},

pm2的日志文件:/root/.pm2/logs下面

查看服务器上运行的NODE服务,执行:pm2 list
删除一个服务,执行pm2 delete [appName]