`npm config edit` reformats file, stripping user comments

What I Wanted to Do

Use npm config edit and see my semi-colon prefaced comments remain after opening.

What Happened Instead

The uncommented portions were preserved but the commented portions were not.

Reproduction Steps

  1. Add a semi-colon prefaced comment line at the top of one’s .npmrc file.
  2. Watch it be stripped upon running npm config edit

Details

Platform Info

$ npm --versions

{ npm: '6.11.3',
  ares: '1.14.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.33.0',
  node: '10.11.0',
  openssl: '1.1.0i',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.0',
  v8: '6.8.275.32-node.28',
  zlib: '1.2.11' }

$ node -p process.platform
<!-- paste output here -->
darwin

Previously reported here: npm commit strips out comments

1 Like