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.
Can I remove package lock JSON? delete both node-module and package-lock. json, then run npm install then npm start.
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 .
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!
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With