mysticatea / npm-run-all

A CLI tool to run multiple npm-scripts in parallel or sequential.
MIT License
5.72k stars 240 forks source link

Infinite loop with npm.run() #181

Closed NoriSte closed 4 years ago

NoriSte commented 5 years ago

Hi I found a bug while launching an npn-run-all-based script with npm.run(). You can watch the bug opening this example on CodeSandbox or play with the repo that I shared.

The issue is: if I have a

"run:examples:s": "npm-run-all -s example:**"

script in my package.json file and if I leverage the native

npm.run("run:examples:s") API to run a script (instead of the standard $ npm run run:examples:s)

npm-run-all goes to an infinite loop.

I hope it's clear, let me know if you need me to explain it better.

Anyway: thank you so much for the amazing library 😊 Thank you Stefano

mysticatea commented 5 years ago

Thank you for your report.

But that's not a bug in npm-run-all.

The cause is that you set $npm_execpath environment variable with an invalid value. The $npm_execpath must be a valid path to npm or a compatibility tool. But the npm.run() function seems to set require.main.filename to the environment variable. In your case, that value is not an npm compatibility tool.

NoriSte commented 5 years ago

Hi @mysticatea Thank you so much for the feedback! I'm trying to find a feasible path to solve the problem but I think I can't do anything to solve that 😕

Do you have more suggestions about how I can handle the problem? Thank you so much Stefano

mysticatea commented 5 years ago

I think that you should open an issue at https://github.com/npm/npm-lifecycle.