Install dependencies in Heroku error building

Viewed 10

I'm new to use Heroku, i try to push my code, when I run command to deploy the project 'git

push heroku master', it fails to install dependencies, and I receive this error message:

  Compressing source files... done.
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):  16.13.0
remote:        engines.npm (package.json):   8.6.0
remote:
remote:        Resolving node version 16.13.0...
remote:        Downloading and installing node 16.13.0...
remote:        Bootstrapping npm 8.6.0 (replacing 8.1.0)...
remote:        npm 8.6.0 installed
remote:
remote: -----> Installing dependencies
remote:        Installing node modules
remote:        npm ERR! code 1
remote:        npm ERR! path /tmp/build_cfd264a5/node_modules/bcrypt
remote:        npm ERR! command failed
remote:        npm ERR! command sh -c node-gyp rebuild
remote:        npm ERR! gyp info it worked if it ends with ok
remote:        npm ERR! gyp info using node-gyp@9.0.0
remote:        npm ERR! gyp info using node@16.13.0 | linux | x64
remote:        npm ERR! gyp info find Python using Python version 3.10.4 found at "/usr/bin/python3"
remote:        npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.0/node-v16.13.0-headers.tar.gz
remote:        npm ERR! gyp http 200 https://nodejs.org/download/release/v16.13.0/node-v16.13.0-headers.tar.gz
remote:        npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.0/SHASUMS256.txt
remote:        npm ERR! gyp http 200 https://nodejs.org/download/release/v16.13.0/SHASUMS256.txt
remote:        npm ERR! gyp info spawn /usr/bin/python3
remote:        npm ERR! gyp info spawn args [
remote:        npm ERR! gyp info spawn args   '/tmp/build_cfd264a5/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
remote:        npm ERR! gyp info spawn args   'binding.gyp',
remote:        npm ERR! gyp info spawn args   '-f',
remote:        npm ERR! gyp info spawn args   'make',
remote:        npm ERR! gyp info spawn args   '-I',
remote:        npm ERR! gyp info spawn args   '/tmp/build_cfd264a5/node_modules/bcrypt/build/config.gypi',
remote:        npm ERR! gyp info spawn args   '-I',
remote:        npm ERR! gyp info spawn args   '/tmp/build_cfd264a5/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
remote:        npm ERR! gyp info spawn args   '-I',
remote:        npm ERR! gyp info spawn args   '/app/.cache/node-gyp/16.13.0/include/node/common.gypi',
remote:        npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
remote:        npm ERR! gyp info spawn args   '-Dvisibility=default',
remote:        npm ERR! gyp info spawn args   '-Dnode_root_dir=/app/.cache/node-gyp/16.13.0',
remote:        npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/tmp/build_cfd264a5/.heroku/node/lib/node_modules/npm/node_modules/node-gyp',
remote:        npm ERR! gyp info spawn args   '-Dnode_lib_file=/app/.cache/node-gyp/16.13.0/<(target_arch)/node.lib',
remote:        npm ERR! gyp info spawn args   '-Dmodule_root_dir=/tmp/build_cfd264a5/node_modules/bcrypt',
remote:        npm ERR! gyp info spawn args   '-Dnode_engine=v8',
remote:        npm ERR! gyp info spawn args   '--depth=.',
remote:        npm ERR! gyp info spawn args   '--no-parallel',
remote:        npm ERR! gyp info spawn args   '--generator-output',
remote:        npm ERR! gyp info spawn args   'build',
remote:        npm ERR! gyp info spawn args   '-Goutput_dir=.'
remote:        npm ERR! gyp info spawn args ]
remote:        npm ERR! gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
remote:        npm ERR! gyp ERR! configure error
remote:        npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
remote:        npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/tmp/build_cfd264a5/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
remote:        npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
remote:        npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
remote:        npm ERR! gyp ERR! System Linux 4.4.0-1104-aws
remote:        npm ERR! gyp ERR! command "/tmp/build_cfd264a5/.heroku/node/bin/node" "/tmp/build_cfd264a5/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
remote:        npm ERR! gyp ERR! cwd /tmp/build_cfd264a5/node_modules/bcrypt
remote:        npm ERR! gyp ERR! node -v v16.13.0
remote:        npm ERR! gyp ERR! node-gyp -v v9.0.0
remote:        npm ERR! gyp ERR! not ok
remote:
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.BsIF2/_logs/2022-09-11T08_57_58_313Z-debug-0.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: c0bd8df732946d1ac719cff0e4ceb2fa5f9f96c2
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version c0bd8df732946d1ac719cff0e4ceb2fa5f9f96c2
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy....

This is my package json with node and npm version:

{
  "name": "backend",
  "version": "1.0.0",
  "engines": {
    "node": "16.13.0",
    "npm": "8.6.0"
  },
  "description": "",
  "main": "server.js",
  "scripts": {
    "dev": "cross-env NODE_ENV=development node server.js",
    "prod": "cross-env NODE_ENV=production node server.js",
    "test": "cross-env NODE_ENV=production mocha 'test/apiTest.js'"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^5.0.0",
    "body-parser": "^1.19.0",
    "compression": "^1.7.4",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "ejs": "^2.6.1",
    "express": "^4.17.1",
    "express-jwt": "^5.3.1",
    "jsonwebtoken": "^8.5.1",
    "jw-paginate": "^1.0.4",
    "memory-cache": "^0.2.0",
    "minimist": "*",
    "multer": "^1.4.2",
    "mysql": "^2.17.1",
    "node-fpe": "^1.0.0",
    "nodemailer": "^6.4.17",
    "paypal-rest-sdk": "^1.8.1",
    "stripe": "^8.132.0",
    "swagger-jsdoc": "^3.5.0",
    "swagger-node-express": "^2.1.3",
    "swagger-ui-express": "^4.1.2"
  },
  "devDependencies": {
    "cross-env": "^7.0.3",
    "supertest": "^6.1.3"
  }
}

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

Does anybody know how I can fix it?

0 Answers
Related