I need to create a git repository for my project and share it with others through Github. But I've heard that we don't need to include the node_modules folder when we commit the changes to the git repository. Others can Run npm install and install those modules themselves instead. My question is do I also need to ignore the package-lock.json file when I ignore the node_modules folder? I couldn't find the package-lock.json file on the projects I've downloaded from the Internet so far. That package-lock.json file was created automatically when I ran npm install. So I have a doubt on whether to commit the package-lock.json file on my git repository or not.
Asked
Active
Viewed 57 times
0
-
This is really an npm usage question. Git will store your file in commits if you include it in the commits; listing the file in `.gitignore` doesn't *exclude* it from commits (which are made from Git's *index*) but *does* stop it from becoming "tracked" (included in Git's index) if it is not *already* "tracked" this way, so it's a good way to keep from *accidentally* committing the file. Whether you want it committed, though, is not a question for Git, which doesn't care one way or the other. – torek Jun 03 '22 at 11:11
-
For the npm side, see [What is the role of the package-lock.json?](https://stackoverflow.com/q/44297803/1256452) and [Do I commit the package-lock.json file created by npm 5?](https://stackoverflow.com/q/44206782/1256452) – torek Jun 03 '22 at 11:14