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

Issue

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: 
remote: -----> Building on the Heroku-22 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:        
remote: -----> Creating runtime environment
remote:        
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        
remote: -----> Installing binaries
remote:        engines.node (package.json):  15.3.0
remote:        engines.npm (package.json):   7.0.14
remote:        
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:        
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:        
remote: -----> Prebuild
remote:        Running heroku-prebuild
remote:        
remote:        > snazzywiz@2.1.1 heroku-prebuild
remote:        > npm --global install pushstate-server@3.0.1; npm --global install @angular/cli
remote:        
remote:        
remote:        added 44 packages, and audited 44 packages in 3s
remote:        
remote:        10 vulnerabilities (5 low, 3 moderate, 2 high)
remote:        
remote:        To address issues that do not require attention, run:
remote:          npm audit fix
remote:        
remote:        To address all issues, run:
remote:          npm audit fix --force
remote:        
remote:        Run `npm audit` for details.
remote:        
remote:        added 209 packages, and audited 209 packages in 8s
remote:        
remote:        25 packages are looking for funding
remote:          run `npm fund` for details
remote:        
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:        
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:        
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: 
remote: -----> Build failed



Solution

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?