npm run script hook #15443

mavericken opened this Issue Jan 10, 2017 · 0 comments


None yet

1 participant


I propose exposing a hook to allow for increased windows compatibility for run-script. NPM run script has become increasingly popular lately as a replacement for grunt and gulp. The problem is that it is easy to encounter module maintainers who may be apathetic or hostile towards windows compatibility, and they are using commands in their run-script that won't work on windows (and in some cases even refusing PRs which fix the issue...)

What's the feature?

Have a global setting that can be used to run some code prior to executing an npm script. This code would be able to see the command and the current directory, and would have an opportunity to make adjustments to the command before running it, or perhaps run the command itself.

What problem is the feature intended to solve?

Eventually this could allow Windows users to run most bash style npm scripts without a VM or WSL.
We could solve many error conditions, such as:

  1. Environment variable syntax
  2. Deal with & and &&
  3. Redirect / piping syntax issues
  4. Relative paths commands with forward slashes

I recognize that a perfect solution to all the bash<=>cmd issues is either super difficult or impossible, but having a hook would allow for an effort external to NPM's development cycle which could build and evolve something to handle as many use cases as possible.

Is the absence of this feature blocking you or your team? If so, how?

No, I have a Linux VM and I know how to use it. I would comment though, that cross-platform compatibility is the primary reason I started using node.js, and as a Windows user, it is disheartening to see some community members who are the among the greatest beneficiaries of cross-platform development becoming obstacles to it.

Is this feature similar to an existing feature in another tool?

We just need the ability to do something like those without having to shim it into each and every package.

Is this a feature you're prepared to implement, with support from the npm CLI team?


I found some existing issues that would could be better resolved if we could do this:

It wasn't very hard to find those, and there are probably dozens more.

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