Elio
Elio

Reputation: 468

how to prevent "npm install" change package.json

I have a Maven project where I execute npm install in build with the com.github.eirslett frontend-maven-plugin plugin.

My problem is that after the build, git says me that the package.json has been changed, although when I check the diff (in IntelliJ) it says Contents are identical. If i run stat package.json I see that all timestamps of the file have been changed.

How can I avoid npm install changing the package.json file?

Solution: See answer from James Monger

Upvotes: 6

Views: 1751

Answers (1)

James Monger
James Monger

Reputation: 10665

You can make a .gitattributes file in your project root with the following contents:

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

That will specify that package.json and package-lock.json should always use LF file endings.

Upvotes: 3

Related Questions