npm ci doesn't respect .npmrc variables

(Denis Bendrikov) #1

What I Wanted to Do

I wanted npm ci to catch up .npmrc variables.

We have a requirement to use private in-house registry and wanted to use node-sass package from that registry.

The problem is β€” node-sass internally uses postinstall script which tries to download precompiled sass binaries, and expect them from a various places one of which is a variable in .npmrc.

Further this variables are used like that:

What Happened Instead

Looks like npm ci doesn’t collect npmrc variables into process.env.npm_config_variable_name (as npm i do).

Reproduction Steps

If this behavior is not intended, then here is a repro steps:

npm init -y
npm i node-sass -D

# node-sass tries to cache downloaded binaries in this places, so clean them
rm -rf node_modules/
rm -rf ~/.npm/node-sass/

npm config set sass_binary_site http://path-to-local-registry-that-should-be-visible-in-npm-ci-log
npm ci

somewhere in logs we should see our URL from sass_binary_site ( http://path-to-local-registry-that-should-be-visible-in-npm-ci-log/v4.11.0/linux-x64-64_binding.node ).

But we saw the default one

> node-sass@4.11.0 install /home/denis/temp/node_modules/node-sass
> node scripts/install.js

Downloading binary from


If we run npm i - sass_binary_site variable will be taken into account.

Platform Info

$ npm --versions
{ 'npm-bug-repro': '1.0.0',
  npm: '6.9.0',
  ares: '1.14.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.13.0',
  openssl: '1.1.0i',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '',
  zlib: '1.2.11' }
$ node -p process.platform