Warning for Lift-off Part 5: Do not commit your package-lock.json updates

I reached the deploying apollo client step of the course. After following the instructions, I committed the updated package-lock.json and index.js and pushed to my remote.

The Heroku build kept failing with issues about out-of-sync dependencies. I pulled my hair out for a while trying to get versions in sync. I even updated a lot of them, but no configuration of dependencies seemed to work for the Heroku build (even though they worked fine locally).

I finally started fresh and did not touch package-lock.json. This fixed the build issue.

I hope the project maintainers will evaluate and upgrade their dependencies to make this less fragile going forward. In the meantime, I hope this is helpful for anyone who encounters this issue!

Example error

-----> Installing dependencies
       Installing node modules
       npm ERR! code EUSAGE
       npm ERR! 
       npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
       npm ERR! 
       npm ERR! Invalid: lock file's @babel/core@7.12.3 does not satisfy @babel/core@7.18.9
       npm ERR! Missing: @ampproject/remapping@2.2.0 from lock file
       npm ERR! Invalid: lock file's @babel/code-frame@7.14.5 does not satisfy @babel/code-frame@7.18.6
       npm ERR! Invalid: lock file's @babel/generator@7.14.8 does not satisfy @babel/generator@7.18.9
       npm ERR! Invalid: lock file's @babel/helper-compilation-targets@7.14.5 does not satisfy @babel/helper-compilation-targets@7.18.9
       npm ERR! Invalid: lock file's @babel/helper-module-transforms@7.14.8 does not satisfy @babel/helper-module-transforms@7.18.9
       npm ERR! Invalid: lock file's @babel/helpers@7.14.8 does not satisfy @babel/helpers@7.18.9
       ...
-----> Build failed

In addition, I would suggest updating the instructions to have people run npm ci locally instead of npm install. This would avoid updating the lock file altogether.

Thank you for your message @paupollo.
I was indeed able to reproduce and pushed a fix to the demo repo.
Thank you so much for spotting this, sharing your findings here for the community and for us to fix the issue.
Have a great day and thanks for learning with us!

Best,
Raph

1 Like