npm ci deletes hooks from node_modules

What I Wanted to Do

I tried to build my application on Jenkins running ‘npm ci’ instead of the developer variant ‘npm i’. We have a preinstall-hook in ‘node_modules/.hooks’ to fix an issue in one of our dependencies.

What Happened Instead

NPM deletes the node_modules folder, including the ‘.hooks’ directory, and then tries to install all dependencies. Since our fix is never run, npm is unable to correctly install one of the modules and subsequently aborts the build with an error.

Reproduction Steps

Because of my company running behind a proxy, I need to ‘fix’ some dependencies that have their node-gyp download URLs ‘incorrectly’ configured. Unfortunately I therefor can’t give an easy description of how to reproduce this problem.
A possible to way to see what is happening though, would be to add a hook in ‘node_modules/.hooks’, add it to GIT and then run ‘npm ci’. Afterwards check ‘git status’ to see that the hook was actually deleted from the filesystem.

Platform Info

$ npm --versions
{
npm: ‘6.11.3’,
ares: ‘1.15.0’,
brotli: ‘1.0.7’,
cldr: ‘35.1’,
http_parser: ‘2.8.0’,
icu: ‘64.2’,
llhttp: ‘1.1.4’,
modules: ‘72’,
napi: ‘5’,
nghttp2: ‘1.39.2’,
node: ‘12.11.1’,
openssl: ‘1.1.1c’,
tz: ‘2019a’,
unicode: ‘12.1’,
uv: ‘1.32.0’,
v8: ‘7.7.299.11-node.12’,
zlib: ‘1.2.11’
}

$ node -p process.platform
darwin

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.