[node & express] Build is failing on CI while installing deps, working fine on local

I am following the Back End Development and APIs track. I have forked freeCodeCamp/boilerplate-express and setup a CI with Heroku.

I am getting some npm issue which I was able to dodge before this lesson. But this lesson forces to install a new package called dotenv. I’m at https://www.freecodecamp.org/learn/back-end-development-and-apis/basic-node-and-express/use-the--env-file.

The error I am getting on Heroku console is:

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 16.x...
       Downloading and installing node 16.14.2...
       Using default npm version: 8.5.0
       
-----> Restoring cache
       - node_modules
       
-----> Installing dependencies
       Installing node modules
       npm ERR! code EINTEGRITY
       npm ERR! sha512-+HXHCtd8IuwfXYZmofQqpQQRr2cZeo1uNzXVse4NDkpBR5pMGOGORLgCWgIyF2YlyI53xZfmKDVTR9UrLfyXmQ== integrity checksum failed when using sha512: wanted sha512-+HXHCtd8IuwfXYZmofQqpQQRr2cZeo1uNzXVse4NDkpBR5pMGOGORLgCWgIyF2YlyI53xZfmKDVTR9UrLfyXmQ== but got sha512-Dhsz3IUF1IcJqxowxiFR/S4pOXwavLsYFsaDcjYBc0q43474qrH3KzhvNaq2WBE4zW7j8pQXW8eMjxBcRK8ENg==. (3969 bytes)
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.fYZWw/_logs/2022-04-14T01_05_07_446Z-debug-0.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

Please help me solve this.

This might not be the best option, but deleting the package-lock.json fixed the problem.