How can I configure npm to use Windows-style line endings in package.json?

徘徊边缘 提交于 2019-11-29 16:48:57

问题


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:


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


来源:https://stackoverflow.com/questions/32490412/how-can-i-configure-npm-to-use-windows-style-line-endings-in-package-json

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!