Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't make git stop tracking package-lock.json

Tags:

git

node.js

npm

With npm v5 here is now package-lock.json file being created after npm install

It is recommended to commit this file, but I have issue that this file is different for some reason between my dev machine and my server. Even if I push that file to repo, after npm install on server, file changes.

So now I'm attempting to make git untrack this file. After following numerous answers from other questions, I seem to have almost managed to do so, it's not tracked on dev machine, doesn't appear in the repo itself, but after I pull code to server and make npm install, it appears in modified files.

File is in .gitignore, but server git for some reason ignores it.

git check-ignore -v -n package-lock.json ::      package-lock.json
git check-ignore -v -n --no-index package-lock.json .gitignore:10:package-lock.json package-lock.json 

Possibly relevant info:

Dev machine: Windows 10. Server: Ubuntu 14.04. I'm pulling code to server using tags.

like image 514
Giedrius Avatar asked Jun 17 '17 04:06

Giedrius


People also ask

How do I stop json from generating package lock?

Can I remove package lock JSON? delete both node-module and package-lock. json, then run npm install then npm start.

Should we push package lock json to Git?

The package-lock. json file needs to be committed to your Git repository, so it can be fetched by other people, if the project is public or you have collaborators, or if you use Git as a source for deployments. The dependencies versions will be updated in the package-lock. json file when you run npm update .

Can I remove package lock json?

json that result in two different installs. You may have noticed it before; you install a package using npm and suddenly a new file called package-lock. json appears in your project directory. Don't delete that package-lock file, run npm install and regenerate it!

Do I need to check in package lock json?

If you're collaborating on a shared project with multiple developers, and you want to ensures that installations remain identical for all developers and environments, you need to use package-lock. json . package-lock. json is automatically generated for any operations where npm modifies either package.


1 Answers

You need to remove it from your repo (git rm package-lock.json) in order for git to stop tracking it.

.gitignore only works for untracked files. If you have a tracked file that is also in your .gitignore, the fact that the file is tracked overrides the fact that it is also in .gitignore.

like image 77
Andy Avatar answered Sep 23 '22 05:09

Andy