首先,安装 concurrently
cnpm install concurrently
在前端package.json中脚本部分:
这里以前端目录为coder为例,写
"scripts": {
"serve": "vue-cli-service serve --open",
"build": "vue-cli-service build",
"start": "npm run serve"
},
在根目录,也就是后端目录的package.json中,把前端的命令行集成一下。
"scripts": {
"client-install": "npm install --prefix coder",
"coder": "npm start --prefix coder",
"start": "node server.js",
"serve": "nodemon server.js",
"dev": "concurrently \"npm run serve\" \"npm run coder\""
},