简体   繁体   English

如何在 unix 和 windows 上运行多个 npm 脚本

[英]How to run multiple npm scripts both on unix and windows

I want to run multiple npm scripts synchronous .(one after another) For example here are my npm scripts.I have both bower and npm packages in my project.我想同步运行多个 npm 脚本。(一个接一个)例如这是我的 npm 脚本。我的项目中有 bower 和 npm 包。

{
  "scripts": {
    "installnpm": "npm i",
    "installbower": "bower i",
    "rimraf":"rimraf dist"
    "lernabootstrap": "lerna bootstrap",
    "start":"nodemon myApp.js"
  }
} 

How can I run multiple scripts both on unix and windows without any error?如何在 unix 和 windows 上运行多个脚本而没有任何错误? Scripts also includes npm and bower install commands like you see.Does it matter for this situation?脚本还包括 npm 和 bower install 命令,如您所见。这种情况有关系吗?

You can run commands synchronously by using && in both Windows and Unix environments.您可以在 Windows 和 Unix 环境中使用&&同步运行命令。

So ...所以 ...

{
  "scripts": {
    "installnpm": "npm i",
    "installbower": "bower i",
    "rimraf":"rimraf dist"
    "lernabootstrap": "lerna bootstrap",
    "start":"nodemon myApp.js",
    "all": "npm run installnpm && npm run installbower && npm run start"
  }
} 

so then you could run npm run all to execute all those npm scripts synchronously那么你可以运行npm run all来同步执行所有这些 npm 脚本

Here is a answer that answers it for Windows and this answer is useful as well.这是一个针对Windows的答案,这个答案也很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM