Question

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

Posted November 12, 2020 146 views
Node.js

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?

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.

×
1 answer

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:
https://www.digitalocean.com/docs/app-platform/languages-frameworks/node/

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.

Cheers,

Dikshith

Submit an Answer