gitignored package-lock.json
See original GitHub issueI prefer to gitignore the package-lock.json
for libraries. I commit the package-lock.json
only for apps.
When the package lock is gitignored, when running standard-version
this happens:
✔ committing package-lock.json and package.json and CHANGELOG.md
The following paths are ignored by one of your .gitignore files:
package-lock.json
Use -f if you really want to add them.
Command failed: git add package.json package-lock.json CHANGELOG.md
The following paths are ignored by one of your .gitignore files:
package-lock.json
Use -f if you really want to add them.
Using -f
will add the package-log to source control which I don’t want. Ideally, standard-version
could detect that the file is gitignored and skip it.
Thoughts?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Do I commit the package-lock.json file created by npm 5?
Short answer: yes. One comment: when package-lock.json changes you can make a commit of just that change, separate from other source changes.
Read more >package-lock.json - in GIT or not? - DEV Community
So, a lock file keeps the version of all our dependencies, and whenever someone runs npm install , they will get the exact...
Read more >Package-lock.json file should be committed #4324 - GitHub
gitignore file. The main purpose of package-lock.json is to guarantee that all contributors install exactly the same dependencies. The npm ...
Read more >Should the package-lock.json file be added to .gitignore?
Depends on the situation, but usually no. You'd only want to add it if there is value in the fixation of the versions....
Read more >Should I include package-lock.json in source control?
To recap, you should always include both package.json and package-lock.json in your source control. Thus, never put them in the .gitignore file.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@satazor Hey, I ran into this same problem today, bit of a pain.
Besides manually running
npm i --no-package-lock
(to avoid the creation of the lock file at all) or adding package-lock.json to the git repo, here are a couple workarounds/hacks I tested that were successful:Rename package-lock.json on prebump and rename it back on posttag
Define a standard-version lifecycle script in your package.json that looks like this:
This maintains the integrity of the lock file but temporarily hides it when running standard-version.
I put this as the first option because it still allows you to get the benefit of using package-lock.json file locally, though that value is arguably moot when not shared.
Remove package-lock.json on postshrinkwrap
Define an npm postshrinkwrap script that looks like this:
This just subverts the normal lock file writing process that occurs with a typical
npm i
(npm will create the file and then immediately delete it on install). This works whether you’re using standard-version or not.(Note that I also tried to do this with a postinstall script, but postinstall runs before npm creates the lock file.)
Remove package-lock.json on prebump
Define a standard-version lifecycle script in your package.json that looks like this:
This just removes the file when you go to cut a new release. The next time you run
npm i
, the lock file will be recreated.That being said, it would obviously be nice if standard-version detected that the file is git-ignored, but until we can add that, one of the above options is probably the best we can do. HTH!
With #230 (and likely some updates since),
standard-version
will respect.gitignore
. Since thepackage-lock.json
is a bit of a special case (defaultbumpFile
), I’ve expanded our test to make sure it is ignored as expected when found in a local.gitignore
.Thanks to all who contributed to this initial fix/feature! ✌️