concurrently
似乎没有使用&&
,也不知道--suffix --prefix client
应该做什么。你的意思是启动服务器两次?
无论如何,摆脱并在脚本中&&
添加额外内容对我有用--
"client"
package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start -- --suffix --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"concurrently": "^5.3.0",
"nodemon": "^2.0.4"
}
}
server.js
const msg = process.argv[process.argv.length - 1] === 'client' ? 'client' : 'server';
console.log(process.argv.join(' '));
setInterval(() => {
console.log(msg);
}, 2000);