npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm prune --production runs postinstall and breaks jenkins ci build

Steps to Reproduce:

  1. npm i (for first time)

  1. npm ci
  2. npm prune --production => After pruning, it runs postinstall which is breaking the jenkins ci build because in some modules (fetched from github), postinstall script is using dev-dep like babel which won’t be available after pruning. So, eventually npm prune --production also fails.

But, if i remove step 2, then no issue. pruning works fine.

Node Version: 8.12.0
Npm Version: 5.10.0

It’s happening in Npm version 6.8.0 too.

I wasn’t expecting postinstall to run after pruning.

Any idea why is it happening?


So it isn’t the top-level package of whose postinstall script is run? Can you give an example for a GitHub dep that fails to install properly?


app/
package.json

{
dependencies : {
“a”: git+ssh://git@github.com:foo/a.git . (it has postinstall which does babel transformation)
}
devDependencies: {
“babel”: “^6.0.0”
}
}

Now run: npm i => npm ci => It will install these dep/devdep and run those prepublish/postinstall etc.
Now run npm prune --production, once pruning done, it starts running postinstall for module a and then complains that babel doesn’t exist. Obviously, babel got removed after pruning is done.
As per my expectation, it shouldn’t have run postinstall after pruning.

Same works fine, if i don’t use npm ci.


npm ci is missing a bit of info in the package.json files in node_modules/ it seems. The question is whether to add that to npm ci or remove the requirement in the install code (which is shared by npm install, npm prune, npm uninstall, etc.)…