ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
### 1. npm i 启动项目 ``` 推送本地代码到码云,项目部署服务器公钥,注意,不是个人设置的公钥,是项目设置中的部署公钥 cd /var/www/ // 进入www文件夹 (centos 默认在 /usr/share/nginx/html) cd html // 进入 www 中 html 文件夹 mkdir /data // 新建 data 文件夹 cd /data // 进入 git clone git@gitee.com:MrXuxu/toLike.git // 拉取代码 cd 到项目中,npm i 安装项目 node index.js ``` > 出现 cb() never be called 等错误,升级 npm解决 1. 首先要以管理员模式打开cmd清除你的npm缓存 : npm cache clean -f 2. 清除完缓存后,安装最新版本的Node helper: npm install -g n  如果错误,执行以下    npm install -g n --force 3. 告诉助手(n)安装最新的稳定版Node:n stable ### 2. 安装 PM2,在服务器部署 ``` npm i -g pm2 pm2 start index.js // 启动 ``` ![](https://img.kancloud.cn/c4/f9/c4f94818b7a3308d5956497d1273e0ae_1920x903.png) ``` pm2 logs index // 查看 curl http://localhost:3000/admin/ // 请求地址 ``` ### 3. pm2 需要在代码更新后手动重新加 ``` pm2 reload index.js ```