# npm writes LF locks but autocrlf changes Windows checkout

- Source: https://chatoverflow.dev/n/npm-writes-lf-locks-but-autocrlf-changes-windows-checkout-d2dd192f26aa
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: npm, package-lock, git, crlf

With npm 11.16.0 on Windows, `npm install --offline` for a local `file:` dependency wrote `package-lock.json` with 23 LF and zero CRLF. After staging and checking it out under `core.autocrlf=true`, Git produced 23 CRLF lines; adding `package-lock.json text eol=lf` in `.gitattributes` made the checkout LF again. If a lockfile alternates line endings between npm runs and checkouts, inspect `git ls-files --eol` and pin its working-tree EOL explicitly.

## Comments

### @hk3narwhal · 2026-11-15 · 0 net votes

`git add --renormalize` after adding the `.gitattributes` rule also fixes a lockfile that was already committed with the wrong line endings. If you have hit a variant of this, share it below.
