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

[QUESTION] Why does not npm run the local installed executable with npm run command? #610

Closed
ajaymathur opened this issue Dec 18, 2019 · 6 comments
Labels
Awaiting Information further information is requested

Comments

@ajaymathur
Copy link
Contributor

ajaymathur commented Dec 18, 2019

What

If I install an executable as a local dependency in my project. Why does not npm run those executable when called as npm run <executable>?
Install jest in your repository and then you we need add script like "jest": "jest" in our package.json. I just want to know the reason here. I am happy to contribute if it is something we want in npm cli.

Where

npm/cli

Who

  • n/a

References

https://stackoverflow.com/questions/9679932/how-to-use-package-installed-locally-in-node-modules

@ajaymathur ajaymathur changed the title [QUESTION] Why does not npm run the local installed binaries with npm run command? [QUESTION] Why does not npm run the local installed executable with npm run command? Dec 18, 2019
@LitoMore
Copy link

You should use npx instead.

@ajaymathur
Copy link
Contributor Author

Hey @LitoMore , thanks a lot for responding. However, with the existence of npx I am still not sure why we would want to not support running local installed executable with npm run command.
Do you know of a reasoning why we should run it using npx only and npm should not support it?

@ljharb
Copy link
Contributor

ljharb commented Dec 20, 2019

I don't know the original reason, but npm run simply never worked that way before, and it would likely break a lot of people to have npm run foo suddenly start doing what npx foo does.

npx ships with npm, so the barrier to using it should be close to zero.

@ajaymathur
Copy link
Contributor Author

Hey @ljharb, Thanks a lot for responding.

My use case is I am writing docs on how to work with repository. I am using certain tools like https://github.com/atlassian/changesets who's name is actually the relevant command. Now I want to tell user to:

# Install dependencies
$ npm install

# run other scripts with npm

# run changesets
$ npm run changesets # Here I want to maintain using the same command `npm` to avoid confusion

Now I also add a script in package.json as:

"changesets": "changesets"

which seemed not so useful to me. Unless I am missing to see some user aspect here. 🙂

It is not blocking me but I would like to know if there is any strong reason like it will break existing apps or something on similar lines. If not, and we want to consider this then I am happy to contribute. 🙂

@ljharb
Copy link
Contributor

ljharb commented Dec 20, 2019

I would imagine that it would hide bugs, since npx foo will install foo if it isn't already installed.

I think your docs would be clearer if the "run the command that the project set up", was not the same one as "run the command whether the project's set it up or not".

@darcyclarke darcyclarke added the Awaiting Information further information is requested label Oct 30, 2020
@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Information further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants