2

Here is the error I am getting when I go to manually deploy on heroku's website. First I was getting an error in my .json file, so I specified both the "npm", "yarn" and "node" versions I was running. Those errors appeared to clear up. Now I am this one and have searched google but cannot seem to find much on fixing it.

----> Node.js app detected

-----> Creating runtime environment



       NPM_CONFIG_LOGLEVEL=error

       NPM_CONFIG_PRODUCTION=true

       NODE_VERBOSE=false

       NODE_ENV=production

       NODE_MODULES_CACHE=true

-----> Installing binaries

       engines.node (package.json):  9.4.0

       engines.npm (package.json):   5.3.0

       engines.yarn (package.json):  1.3.2



       Resolving node version 9.4.0...

       Downloading and installing node 9.4.0...

       Bootstrapping npm 5.3.0 (replacing 5.6.0)...

       npm 5.3.0 installed

       Resolving yarn version 1.3.2...

       Downloading and installing yarn (1.3.2)...

       Installed yarn 1.3.2

-----> Restoring cache

       Skipping cache restore (not-found)

-----> Building dependencies

       Installing node modules (yarn.lock)

       yarn install v1.3.2

       [1/4] Resolving packages...

       [2/4] Fetching packages...

       info fsevents@1.1.1: The platform "linux" is incompatible with this module.

       info "fsevents@1.1.1" is an optional dependency and failed compatibility check. Excluding it from installation.

       [3/4] Linking dependencies...

       warning "webpack > ajv-keywords@1.5.1" has unmet peer dependency "ajv@>=4.10.0".

       [4/4] Building fresh packages...

       $ webpack --config webpack.prod.js

       /bin/sh: 1: webpack: not found

       error Command failed with exit code 127.

       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

-----> 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

Here is the .json script file:

{
  "name": "gun-c4",
  "version": "0.0.1",
  "description": "Connect four by gunDB",
  "main": "server.js",
  "scripts": {
    "build": "node node_modules/webpack/bin/webpack.js --display-error-details",
    "lint": "eslint src/",
    "start": "node server.js",
    "postinstall": "webpack --config webpack.prod.js",
    "build": "webpack",
    "build:prod": "webpack --config webpack.prod.js",
    "dev": "npm run build -- --watch"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/PsychoLlama/connect-four.git"
  },
  "keywords": [
    "connect-four",
    "game",
    "gun",
    "gunDB",
    "game",
    "real-time"
  ],
  "author": "Jesse Gibson <jesse@gundb.io> (http://techllama.com)",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/PsychoLlama/connect-four/issues"
  },
  "homepage": "https://github.com/PsychoLlama/connect-four#readme",
  "dependencies": {
    "connect-four": "0.0.6",
    "gun": "^0.3.992",
    "random-words": "0.0.1",
    "react": "^15.3.1",
    "react-dom": "^15.3.1",
    "react-router": "^3.0.0"
  },
  "devDependencies": {
    "babel-core": "^6.14.0",
    "babel-loader": "^6.2.7",
    "babel-preset-es2015": "^6.14.0",
    "babel-preset-react": "^6.11.1",
    "css-loader": "^0.26.0",
    "eslint": "^3.4.0",
    "eslint-plugin-react": "^6.2.0",
    "node-sass": "^4.0.0",
    "sass-loader": "^5.0.0",
    "style-loader": "^0.15.0",
    "webpack": "^2.2.1"
  },
  "engines": {
    "node": "9.4.0",
    "npm": "5.3.0",
    "yarn": "1.3.2"
  }
}

Thanks

yre
  • 285
  • 4
  • 12

2 Answers2

2

Try this:

heroku config:set NPM_CONFIG_PRODUCTION=false

Then, in your package.json, replace the "postinstall" you have under "scripts" with this:

"heroku-postbuild": "webpack --config webpack.prod.js",

For other options, see Hosting a production React app built with Wepback on Heroku.

Yoni Rabinovitch
  • 5,171
  • 1
  • 23
  • 34
  • Thanks. Where would I type in: heroku config:set NPM_CONFIG_PRODUCTION=false ? I am using the heroku website deployment method, is there a way to type it in through there. I corrected the "postinstall" aspect. – yre Jan 18 '18 at 13:48
  • You can enter that command wherever you run the heroku CLI (i.e. in your development environment). Alternatively, you can set Heroku config vars via your Heroku dasboard under "Settings". Click on "Reveal Config Vars", and and Key NPM_CONFIG_PRODUCTION with value false. – Yoni Rabinovitch Jan 21 '18 at 07:03
  • DO NOT DO THIS. Many dev dependencies become vulnerabilities in production. – jakenberg May 10 '21 at 00:35
0

If you run bpm module binaries, you need to have them in your $PATH. If the scripts are defined in package.json, these binaries will automatically be reachable. Otherwise you need to specify where it lies:

./node_modules/.bin/webpack [args...]
William
  • 741
  • 4
  • 9
  • I just added the .json script file, could you please take a look and tell me what could be changed. – yre Jan 18 '18 at 08:09
  • Oh, it looks ok.. just to make sure, add the path prefix to webpack where ever it is and check. Otherwise it might be something else. – William Jan 18 '18 at 08:12
  • add the path prefix to webpack where ever it is and check? not sure I am following. Is there something I must add into the .json file? – yre Jan 18 '18 at 08:19
  • I mean replace “webpack” in the package.json scripts with “./node_modules/.bin/webpack”. You did it at one place, but not all. – William Jan 18 '18 at 08:58
  • Okay I change that when I deployed it gave me this: ` Building dependencies` Installing node modules (yarn.lock) yarn install v1.3.2 [1/4] Resolving packages... error "/tmp/build_94759e05e1f7c0a51f93ea06b13c367c/JoshB67-connect4-4c057b5/node_modules/.bin/webpack" doesn't exist. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. – yre Jan 18 '18 at 14:00