简体   繁体   中英

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.

{
  "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? Scripts also includes npm and bower install commands like you see.Does it matter for this situation?

You can run commands synchronously by using && in both Windows and Unix environments.

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

Here is a answer that answers it for Windows and this answer is useful as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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