Deploying Node app fails with package-lock.json but works with yarn.lock

When I try deploying my node.js app with a package-lock.json file, it fails with the error:

flow-library | 09:58:09 Installing node_modules using npm
flow-library | 09:58:12 npm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or later to generate it, then try again.
flow-library | 09:58:12 
flow-library | 09:58:12 npm ERR! A complete log of this run can be found in:
flow-library | 09:58:12 npm ERR!     /home/apps/.npm/_logs/2020-11-12T09_58_12_025Z-debug.log

When I switch over to included a yarn.lock file - the deploy works. I would prefer to stick with npm as that’s what we’re using through-out our project.

Any ideas when cipm complains about the lack of package-lock.json when it definitely exists?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello @nickoleary

It appears the commit in that package-lock.json file was missing so you were seeing that npm error. You might have to run npm install and commit the package-lock.json file. Both the NPM and Yarn package managers are supported, however, either package-lock.json for NPM projects or yarn.lock for Yarn projects must be committed to the repo alongside the app’s source code.

We have already documented this under limitation:

Tip: When submitting any questions related to App Platform please add the tag “DigitalOcean App Platform” which will filter the community questions to App Platform Specialists.