在CentOS上迁移Node.js可按以下步骤操作:
curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash - # 替换为所需版本
sudo yum install -y nodejs
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm install 16 # 安装最新LTS版
nvm use 16
~/.bashrc
或/etc/profile
:export PATH=$PATH:/path/to/node/bin
source ~/.bashrc
scp
)。npm install
。sudo firewall-cmd --add-port=3000/tcp --permanent
。pm2 start app.js --name "app"
。pm2 startup
。参考来源: