npm ci doesn't install deep git dependencies correctly

What I Wanted to Do

My build pipeline installed a project having multiple git dependencies using npm ci. I expected all dependencies to be installed correctly.

What Happened Instead

The git package is not installed correctly. In node_modules I only find three files: LICENSE, package.json and README.md. I expected lib/ and package-lock.json and other files.

Using npm i, the deep git dependency is installed correctly though.

Reproduction Steps

Use npm ci and npm i to install a project having an npm dependency with a git dependency

Details

The dependency has a git dependency, which is the one missing partly from node_modules

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',
  modules: '64',
  napi: '5',
  nghttp2: '1.39.2',
  node: '10.17.0',
  openssl: '1.1.1d',
  tz: '2019a',
  unicode: '12.1',
  uv: '1.28.0',
  v8: '6.8.275.32-node.54',
  zlib: '1.2.11'

$ node -p process.platform

  linux

I’ve been seeing what I think is the same problem.

It looks like the prepare step is only run in “dev” mode: https://github.com/npm/cli/blob/latest/lib/install.js#L626-L629

I believe I’ve been able to reproduce this install failure but now it’s not doing it. It’s unclear to me if something has changed.

1 Like

You mean not run when NODE_ENV=production ? how is this.dev defined ?

How am I supposed to use the prepare script when using npm ci ?

Found this: Using npm ci does not run prepare script for git modules

Seems it was not fixed