Heroku deploys fails with ”The `npm ci` command can only install with an existing package-lock.json


This Content is from Stack Overflow. Question asked by Jan Nielsen

An older Node application fails to deploy to Heroku with this error:

npm ERR! The `npm ci` command can only install with an existing package-lock.json or
remote npm-shrinkwrap.json with lockfileVersion >= 1

but I have a package-lock.json with:

  "lockfileVersion": 2,

so I’m guessing this is some underlying issue with an unhelpful message. I’ve tried different versions of Node and NPM though I can’t go above Node 12 without making updates to this legacy application…which I’d r e a a a l l y like to avoid.

Any ideas on how to tickle this away?

Full Error

remote: Building source:
remote: -----> Building on the Heroku-22 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote: -----> Creating runtime environment
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote: -----> Installing binaries
remote:        engines.node (package.json):  15.3.0
remote:        engines.npm (package.json):   7.0.14
remote:        Resolving node version 15.3.0...
remote:        Downloading and installing node 15.3.0...
remote:        npm 7.0.14 already installed with node
remote: -----> Restoring cache
remote:        Cached directories were not restored due to a change in version of node, npm, yarn or stack
remote:        Module installation may take longer for this build
remote: -----> Prebuild
remote:        Running heroku-prebuild
remote:        > snazzywiz@2.1.1 heroku-prebuild
remote:        > npm --global install pushstate-server@3.0.1; npm --global install @angular/cli
remote:        added 44 packages, and audited 44 packages in 3s
remote:        10 vulnerabilities (5 low, 3 moderate, 2 high)
remote:        To address issues that do not require attention, run:
remote:          npm audit fix
remote:        To address all issues, run:
remote:          npm audit fix --force
remote:        Run `npm audit` for details.
remote:        added 209 packages, and audited 209 packages in 8s
remote:        25 packages are looking for funding
remote:          run `npm fund` for details
remote:        found 0 vulnerabilities
remote: npm notice 
remote: npm notice New major version of npm available! 7.0.14 -> 8.19.2
remote: npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.19.2>
remote: npm notice Run `npm install -g npm@8.19.2` to update!
remote: npm notice 
remote: -----> Installing dependencies
remote:        Installing node modules
remote:        npm ERR! The `npm ci` command can only install with an existing package-lock.json or
remote:        npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
remote:        npm ERR! later to generate a package-lock.json file, then try again.
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.ULXke/_logs/2022-09-17T19_15_54_600Z-debug.log
remote: -----> Build failed


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?