In the scripts section of the package.json, you can use various script-hooks to run automatically when you ‘npm install’ (
preinstall will run before and
postinstall will afterwards for example).
The problem is that when you run npm install -D my-package, it doesn’t run that hook, which is kind of unfortunate. Is this a bug or by design?
In my case, we have to generate a local .npmrc file on the fly with a fresh token from our cloud npm repo before installing. It’s nice to run this process in the
preinstall script but it won’t run when we’re trying to install a specific package.