Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

running two simultanious npm script with & fails on windows #8358

Closed
MylesBorins opened this issue May 25, 2015 · 4 comments
Closed

running two simultanious npm script with & fails on windows #8358

MylesBorins opened this issue May 25, 2015 · 4 comments

Comments

@MylesBorins
Copy link

Only one command runs, second one never starts. This is especially painful if neither command has an "ending state" such as a watch command or a dev server

@othiym23
Copy link
Contributor

That's because cmd.exe doesn't have job control like Unix shells. Because it doesn't know how to run a task in the background, I think it just treats & the same as &&. This is a limitation of the Windows platform, and not something that can be hacked around in npm.

If you need background task execution, you're probably going to have to write a little JavaScript task runner that uses child processes (and handles starting or stopping processes).

@MylesBorins
Copy link
Author

: (

@MylesBorins
Copy link
Author

git bash on windows 8 was running the command as expected when not wrapped in an npm script.

That being said... this is totally a rabbit hole not worth going down.

@rofrol
Copy link

rofrol commented Jul 31, 2015

Use parallelshell. In package.json:

"dev": "parallelshell \"npm run watch\" \"npm run live-server\""

Then run it:

npm run dev

Working example

bennypowers added a commit to bennypowers/mws-restaurant-reviews that referenced this issue Mar 9, 2018
Since windows is amazing, it doesn't run npm scripts in parallel when
one is backgrounded with '&'. see npm/npm#8358
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants