npm ci sets the wrong pwd for prepare scripts (different from npm install)

cli
help-wanted
priority:medium
triaged

(Petter Häggholm) #1

What I Wanted to Do

What Happened Instead

(It makes more sense for this report to combine these sections.)

I have a package with a prepare script, which includes a number of our own packages with various preinstall and occasionally prepare or postinstall scripts. This package fails to build in Gitlab CI.

I’m able to reproduce the issue locally: if I install packages with npm ci, it fails; if I use npm install, it works. The difference is the working directory (verified by adding "echo cwd" to the prepare script).

Our packages are scoped (internal repository): they’re all @client/whatever. The particular package is @client/viewers, and it has a whole bunch of @client/* dependencies. In CI, if I add "echo cwd" to the prepare script, then

  • if I run npm install, it reports /builds/client/viewers
  • if I run npm ci, it reports /builds/client/viewers/node_modules/@client

I would expect prepare scripts to run from the same directory regardless of whether I’m running npm install or npm ci.

Reproduction Steps

At the moment, I do not have a minimal repro case (and the code is proprietary, so unfortunately I cannot share it). If needed, I can try to create a minimal OSS example.

Details

Platform Info

Using nvm, I’ve encountered this across multiple versions, including the latest npm (6.4.1); here’s the example I ran most recently.

$ npm --versions

{ '@client/viewers': '1.1.16',
  npm: '5.8.0',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.11.1',
  openssl: '1.0.2o',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.1',
  v8: '6.2.414.50',
  zlib: '1.2.11' }

$ node -p process.platform

linux


(Kat Marchán) #2

I’m pretty sure this will be fixed by libcipm@2.0.2, which should be in npm@6.4.1. It’s strange that you’re still getting it there. Do you mind re-verifying, making sure you’re actually on 6.4.1 when you do?


(Petter Häggholm) #3

My mistake; it was a CI server with an old version of npm. Sorry about that.