本地项目上传到云服务器 SCP2
- 云服务器需要自己弄一台
- 安装scp2
npm i scp2
- deploy/serve.js
const scpClient = require('scp2');//不能用此插件上传到ftp服务器 scpClient.scp('打包好之后的文件夹 ../build', { host: '服务器主机ip', username: 'root',//一般购买的服务器默认用户名为root 不是宝塔面板的用户名 password: '服务器密码',//不是宝塔面板的密码 path: '/www/wwwroot',//远程放文件的地址 }, function (err) { if (err) { console.log(2222); throw err; } else { console.log(1111); } });
将打包好后的项目上传到ftp服务器 自动上传到服务器脚本 ftp (npm 包)
- ftp服务器
- 安装ftp
npm i ftp
- 新建一个文件夹编写自动部署脚本
- deploy/ftp.js
const Client = require('ftp'); const fs = require('fs'); const path = require(