"postinstall" script does not run after "npm install some-package"
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Description
The recommended way to make sure that patch-package applies its patches is to set it to run within `package.json`'s `postinstall` script.
However, for npm at least, the `postinstall` script is only called when running `npm install` -- _not_ when installing a new package (eg. `npm install lodash`). I've confirmed this myself (just now and prior), and it has also been confirmed by others. (eg. see [here](https://stackoverflow.com/a/57511809/2441655))
This is not ideal, because it means that if someone, say, uninstalls a package that has a patch applied -- but then realizes that they still want/need the package, and reinstalls it -- it will leave their `node_modules` in an incorrect state (without the patch applied).
[This answer here](https://stackoverflow.com/a/51155609/2441655) suggests a possible solution. However, it doesn't work on Windows (I just tried it), because the hook-script filename has to exactly be "postinstall", which makes Windows unable to recognize it as an executable (it just errors with `Exit status 1`, and doesn't run the file, regardless of if I use a (previously) `.exe`, `.js`, `.bat`, or `.cmd` file).
Does anyone know of a way to set up patch-package to run after `npm install XXX` commands, in a way that also works on Windows?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.