Reputation: 839
I have an npm parallel script in my package.json that works on a mac but not on windows:
"myScript": "nodemon ./server.js & cross-env NODE_ENV=development webpack-dev-server"
When it is separated into two scripts to run separately, it works fine on both mac and windows:
"myScript1": "cross-env NODE_ENV=development webpack-dev-server",
"myScript2": "nodemon ./server.js",
I would like to keep the parallel script so that I don't have to run both separately. How do I make this work on windows?
Upvotes: 1
Views: 1319
Reputation: 345
I recommend using npm-run-all I think the syntax is a bit cleaner:
scripts: {
"myScript": "run-p myScript1 myScript2",
"myScript1": "cross-env NODE_ENV=development webpack-dev-server",
"myScript2": "nodemon ./server.js",
}
This npm-run-all package provides 3 CLI commands.
The main command is npm-run-all. We can make complex plans with npm-run-all command.
Both run-s and run-p are shorthand commands.
run-s is for sequential, run-p is for parallel. We can make simple plans with those commands.
Upvotes: 0
Reputation: 3154
I have a workaround for this, using module concurrently. So you script section would look something like this:
scripts: {
"myScript": "concurrently \"npm run myScript1\" \"npm run myScript2\"",
"myScript1": "cross-env NODE_ENV=development webpack-dev-server",
"myScript2": "nodemon ./server.js",
}
Upvotes: 2