How can I configure npm to use Windows-style line

2019-02-08 07:14发布

I run Windows, and when npm modifies my package.json file, it writes it using Unix-style line endings (LF). I want it to use Windows-style line endings (CRLF).

Is there a global config setting, or even a command-line option to make npm use the correct EOL characters?

1条回答
我只想做你的唯一
2楼-- · 2019-02-08 07:26

Update: The even easier fix is to use npm@5.8.0 or newer.

Assuming Git, the easiest "solution" to this problem is to use a .gitattributes file to specify that package.json (and now package-lock.json) should always use LF:

# .gitattributes in project root
package.json text eol=lf
package-lock.json text eol=lf
查看更多
登录 后发表回答