Home > database >  heroku deploy not working when local build works fine - NodeJS Timeout
heroku deploy not working when local build works fine - NodeJS Timeout

Time:10-13

Title says it really - i can build locally but it fails to deploy. Has an issue with Timeout - not sure how to force this to work?

Here's my package.json, and the logs afterwards.

I tried adding Timeout by running a yarn install but then it triggered some other dependency issues with node-gyp

Many thanks for any tips!

Package.json

{
  "name": "api",
  "homepage": ".",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "lint": "eslint .",
    "dev": "NODE_ENV=development nodemon --watch '**/*' -e ts,tsx,js  --ignore 'src/**/*.spec.ts' --exec 'ts-node --project ./tsconfig.json' src/server.ts",
    "start": "node ./dist/server.js",
    "start:redis": "docker-compose up -d",
    "build": "NODE_ENV=production tsc"
  },
  "engines":{
    "node":"14.15.5",
    "npm": "6.14.11",
    "yarn": "1.22.15"
  },
  "license": "MIT",
  "main": "dist/server.js",
  "devDependencies": {
    "@types/cookie": "^0.4.0",
    "@types/puppeteer": "^5.4.4",
    "@types/ramda": "^0.27.44",
    "@types/redis": "^2.8.31",
    "@types/user-agents": "^1.0.2",
    "@typescript-eslint/eslint-plugin": "^4.19.0",
    "@typescript-eslint/parser": "^4.19.0",
    "eslint": "^7.22.0",
    "eslint-config-prettier": "^8.1.0",
    "nodemon": "^2.0.12",
    "prettier": "~2.2.1",
    "tslib": "^2.0.0",
    "typescript": "^4.0.0"
  },
  "dependencies": {
    "axios": "^0.21.1",
    "body-parser": "^1.19.0",
    "chalk": "^4.1.2",
    "cookie": "^0.4.1",
    "cookie-parser": "^1.4.5",
    "cors": "^2.8.5",
    "dotenv": "^10.0.0",
    "express": "^4.17.1",
    "express-async-router": "^0.1.15",
    "express-query-boolean": "^2.0.0",
    "node-fetch": "^2.6.1",
    "puppeteer": "^10.2.0",
    "puppeteer-extra": "^3.1.18",
    "puppeteer-extra-plugin-adblocker": "^2.11.11",
    "puppeteer-extra-plugin-stealth": "^2.7.8",
    "ramda": "^0.27.1",
    "redis": "^3.1.2",
    "user-agents": "^1.0.738",
    "util": "^0.12.4"
  }
}

Build logs

> 

-----> 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):  14.15.5

       engines.npm (package.json):   6.14.11

       engines.yarn (package.json):  1.22.15

       

       Resolving node version 14.15.5...

       Downloading and installing node 14.15.5...

       npm 6.14.11 already installed with node

       Resolving yarn version 1.22.15...

       Downloading and installing yarn (1.22.15)

       Installed yarn 1.22.15

       

-----> Restoring cache

       Cached directories were not restored due to a change in version of node, npm, yarn or stack

       Module installation may take longer for this build

       

-----> Installing dependencies

       Installing node modules (package.json)

       

       > puppeteer@10.4.0 install /tmp/build_e4061cb3/node_modules/puppeteer

       > node install.js

       

       

       

       > nodemon@2.0.13 postinstall /tmp/build_e4061cb3/node_modules/nodemon

       > node bin/postinstall || exit 0

       

       Love nodemon? You can now support the project via the open collective:

        > https://opencollective.com/nodemon/donate

       

       added 477 packages from 392 contributors and audited 479 packages in 31.801s

       

       76 packages are looking for funding

         run `npm fund` for details

       

       found 0 vulnerabilities

       

       

-----> Build

       Running build

       

       > api@0.0.1 build /tmp/build_e4061cb3

       > NODE_ENV=production tsc

       

       node_modules/puppeteer/lib/types.d.ts(3644,28): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'.

       node_modules/puppeteer/lib/types.d.ts(6489,71): error TS2583: Cannot find name 'BigInt'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2020' or later.

       node_modules/puppeteer/lib/types.d.ts(6894,28): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'.

npm ERR! code ELIFECYCLE

npm ERR! errno 2

npm ERR! api@0.0.1 build: `NODE_ENV=production tsc`

npm ERR! Exit status 2

npm ERR! 

npm ERR! Failed at the api@0.0.1 build script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

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

npm ERR!     /tmp/npmcache.LPsTK/_logs/2021-10-13T12_15_23_280Z-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

CodePudding user response:

The problem seems to be missing types, here are two possible fix:

  1. Install @types/node as a devDependencies. This package contains types for NodeJS, including the Timeout type.

  2. Edit your tsconfig.json to set skipLibCheck to true:

{
  "compilerOptions": {
    "skipLibCheck": true
  }
}

This will ignore type errors in d.ts files (your error come from node_modules/puppeteer/lib/types.d.ts so it should fix it).

  • Related