npm 运行多个指令concurrently 不同目录 --prefix
文章目录解析运行多个命令concurrently运行指定目录的命令核心示例目录结构client/package.jssonpackage.jsson运行 在node_vue 目录在client运行 node和vue脚手架解析运行多个命令concurrentlyconcurrently npm 文档concurrently安装npm i concurrently --save-devpackage.
·
文章目录
解析
运行多个命令 concurrently
concurrently安装
npm i concurrently --save-dev
package.json
"scripts":{
"order1":"node a.js",
"order2":"node b.js",
// 运行多个指令
"multiple":"concurrently \"npm run order1\" \"npm run order2\""
}
运行
npm run multiple
运行指定目录的命令
语法
"scripts":{
// --prefix client 单前目录下的client
// 指定命令?? 会默认执行client 下package.json 的 start命令
"client":"npm start --prefix client",
}
核心示例
目录结构
client/package.jsson
{
"name": "client",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"start": "npm run serve" // 配置该命令
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^2.6.11"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
package.jsson
{
"name": "node_vue",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"concurrently": "^5.3.0",
"express": "^4.17.1"
},
"devDependencies": {},
"scripts": {
"start":"nodemon app.js",
"client":"npm start --prefix client",
"dev":"concurrently \"npm run start\" \"npm run client\""
},
"keywords": [],
"author": "",
"license": "ISC"
}
运行 在node_vue 目录
npm run dev
在client运行 node和vue脚手架
client/package.json
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"start": "npm run serve",
"up":"node ../app.js",
"dev":"concurrently \"npm run serve\" \"npm run up\" "
},
更多推荐
已为社区贡献4条内容
所有评论(0)