`npm i` rewrites file using different line endings


(Langdon Oliver) #1

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.


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
 ^ It's Windows 10

(Kat Marchán) #2

This was fixed in npm@5.7.1. Please upgrade.

(system) #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.