1、首先需要安装 npm install concurrently
2、切换到vue项目,修改package.json
添加 “start”: “npm run serve”
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"start": "npm run serve"
},
3、然后切换到Node项目上,修改package.json
添加
“client-install”: “npm install --prefix client”
“client”: “npm start --prefix client”
“dev”: “concurrently “npm run server” “npm run client””
"scripts": {
"client-install": "npm install --prefix client",
"client": "npm start --prefix client",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js",
"server": "nodemon serve.js",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
4、在node的终端上运行 npm run dev
5、然后两个项目可以同时运行