如何配置 npm 以在 package.json 中使用 Windows 样式的行结尾? [英] How can I configure npm to use Windows-style line endings in package.json?

查看:60
本文介绍了如何配置 npm 以在 package.json 中使用 Windows 样式的行结尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行 Windows,当 npm 修改我的 package.json 文件时,它使用 Unix 样式的行结尾 (LF) 写入它.我希望它使用 Windows 风格的行尾 (CRLF).

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).

是否有全局配置设置,甚至命令行选项可以让 npm 使用正确的 EOL 字符?

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

推荐答案

更新: 更简单的解决方法是使用 npm@5.8.0 或更新版本.

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

假设 Git,这个问题最简单的解决方案"是使用 .gitattributes 文件来指定 package.json(现在 package-lock.json) 应始终使用 LF:

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

这篇关于如何配置 npm 以在 package.json 中使用 Windows 样式的行结尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆