npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

`npm i` rewrites file using different line endings

What I Wanted to Do

Run npm i through Jenkins on Windows so I could also run a build and deployment script.

What Happened Instead

Everything ran fine, except that package.json and package-lock.json were both rewritten despite there being no real changes using LF instead of CRLF (remember, I’m on Windows), which caused the build and deployment script to think tracked files had changed and the repo wasn’t clean, so it ultimately failed.

Reproduction Steps

On Windows, simply run npm i in a directory where package.json already exists and has CRLF line endings.

Details

This didn’t happen in the past when I was on Node 6 (not sure of the NPM version). I’ve had to rejigger all my scripts to get around it, but it’s still quite jarring to me and other devs to run git clone && npm i, and immediately have pending changes.

Platform Info

$ npm --versions
{ npm: '5.6.0',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.32.0',
  node: '8.11.3',
  openssl: '1.0.2o',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.1',
  v8: '6.2.414.54',
  zlib: '1.2.11' }
$ node -p process.platform
win32
 ^ It's Windows 10


This was fixed in npm@5.7.1. Please upgrade.