【问题标题】:how to prevent "npm install" change package.json如何防止“npm install”更改 package.json
【发布时间】:2018-10-02 07:59:22
【问题描述】:

我有一个 Maven 项目,我在其中使用 com.github.eirslett frontend-maven-plugin 插件在构建中执行 npm install

我的问题是,在构建之后,git 告诉我 package.json 已更改,尽管当我检查差异(在 IntelliJ 中)它说 Contents are identical。如果我运行 stat package.json 我会看到文件的所有时间戳都已更改。

如何避免 npm install 更改 package.json 文件?

解决方案:查看James Monger的回答

【问题讨论】:

标签: node.js git npm npm-install


【解决方案1】:

您可以在项目根目录中创建一个.gitattributes 文件,内容如下:

package.json text eol=lf
package-lock.json text eol=lf

这将指定package.jsonpackage-lock.json 应始终使用LF 文件结尾。

【讨论】:

    猜你喜欢
    • 2019-02-27
    • 1970-01-01
    • 2016-10-02
    • 2021-08-04
    • 2019-07-01
    • 1970-01-01
    • 2019-01-23
    • 2015-07-16
    • 2018-12-29
    相关资源
    最近更新 更多