How to create package-lock.json

i have created a website on glitch here witch run successful, when i export to github and try to deploy to heroku, i have an error insisting i produce a package-lock.json:
ERROR: npm ERR! cipm 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.

TOTAL ERROR:



-----> Building on the Heroku-20 stack

-----> Determining which buildpack to use for this app

-----> Node.js app detected

       

-----> Creating runtime environment

       

       NPM_CONFIG_PRODUCTION=false

       NPM_CONFIG_LOGLEVEL=error

       NODE_VERBOSE=false

       NODE_ENV=production

       NODE_MODULES_CACHE=true

       

-----> Installing binaries

       engines.node (package.json):  12.x

       engines.npm (package.json):   unspecified (use default)

       

       Resolving node version 12.x...

       Downloading and installing node 12.22.6...

       Using default npm version: 6.14.15

       

-----> Installing dependencies

       Installing node modules

       npm ERR! cipm 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! 

       npm ERR! Missing: body-parser@^1.19.0

       npm ERR! Missing: bcryptjs@^2.4.3

       npm ERR! Missing: cookie-parser@^1.4.5

       npm ERR! Invalid: lock file's express-session@1.17.1 does not satisfy express-session@^1.17.2

       npm ERR! Missing: express-validator@^6.12.0

       npm ERR! Missing: jsonwebtoken@^8.5.1

       npm ERR! Missing: memorystore@^1.6.6

       npm ERR! Invalid: lock file's mongodb@3.5.9 does not satisfy mongodb@^3.6.10

       npm ERR! Invalid: lock file's mongoose@5.9.26 does not satisfy mongoose@^5.13.3

       npm ERR! Invalid: lock file's pug@3.0.0 does not satisfy pug@^3.0.2

       npm ERR! Missing: nodemailer@^6.6.3

       npm ERR! Missing: dotenv@^10.0.0

       npm ERR! Missing: path@^0.12.7

       npm ERR! Missing: objectid@^3.2.1

       npm ERR! Missing: compression@^1.7.4

       npm ERR! Missing: helmet@^4.6.0

       npm ERR! 

       

       npm ERR! A complete log of this run can be found in:

       npm ERR!     /tmp/npmcache.vo8SB/_logs/2021-09-26T21_34_24_225Z-debug.log

-----> Build failed

       

       We're sorry this build is failing! You can troubleshoot common issues here:

       https://devcenter.heroku.com/articles/troubleshooting-node-deploys

       

       If you're stuck, please submit a ticket so we can help:

       https://help.heroku.com/

       

       Love,

       Heroku

       

 !     Push rejected, failed to compile Node.js app.

 !     Push failed

NOTE: How can i create package-lock.json file on glitch

This seems like more of a Heroku related issue, could you possibly contact their support team?

nana-sv, check that your .gitignore file doesn’t include package-lock.json

Otherwise I’m not sure what the issue is. Your project should normally include a package-json that’s up to date with your package.json, because Glitch re-runs pnpm install quite often :man_shrugging:

I have some projects on Glitch that started out using pnpm, which creates shrinkwrap.yaml instead of package-lock.json. If you’ve tried everything else and there’s still no package-lock generated, maybe try enable-npm to have Glitch use npm, which generates the package-lock.json. Or maybe there’s a way to have pnpm generate it, but I haven’t looked into that.

1 Like