Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop with npm.run() #181

Closed
NoriSte opened this issue Oct 17, 2019 · 3 comments
Closed

Infinite loop with npm.run() #181

NoriSte opened this issue Oct 17, 2019 · 3 comments
Labels

Comments

@NoriSte
Copy link

NoriSte commented Oct 17, 2019

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
Copy link
Owner

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
Copy link
Author

NoriSte commented Oct 18, 2019

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 😕

  • npm sets the $npm_execpath during the npm.run() execution, so I can't set it just before it runs the npm-run-all-based command
  • npm-run-allaccepts an npmPath option. I could add it if I detect that the script body contains npm-run-all, run-s, etc. but I can't identify it in a subsequent command

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

@mysticatea
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 participants