Reputation: 533
I am trying to deploy my app through Heroku, which is working perfectly on localhost. Even though I had some troubles installing java module on localhost, I finally did it, thanks to this post: https://github.com/nodejs/node/issues/10289.
Now, I'm getting apparently the same error deploying the app on Heroku, but now I'm not able to fix it. I set even the Java Buildpack, just in case, but it didnt help.
I hope someone could help me!
This is my package.json:
{
"name": "tachology",
"version": "0.0.0",
"main": "server/index.js",
"dependencies": {
"angular": "~1.6.0",
"angular-animate": "~1.6.0",
"angular-aria": "~1.6.0",
"angular-cookies": "~1.6.0",
"angular-resource": "~1.6.0",
"angular-sanitize": "~1.6.0",
"angular-ui-router": "^0.4.2",
"angular-validation-match": "^1.9.0",
"babel-polyfill": "^6.7.2",
"babel-runtime": "^6.6.1",
"bluebird": "^3.3.3",
"body-parser": "^1.13.3",
"cal-heatmap": "^3.6.2",
"composable-middleware": "^0.3.0",
"connect-mongo": "^1.2.1",
"cookie-parser": "^1.3.5",
"core-js": "^2.2.1",
"errorhandler": "^1.4.2",
"express": "^4.13.3",
"express-jwt": "^5.0.0",
"express-session": "^1.11.3",
"fast-json-patch": "^1.0.0",
"font-awesome": ">=4.1.0",
"gridfs": "^1.0.0",
"java": "^0.8.0",
"jquery": "^3.2.1",
"jsonformatter": "^0.6.0",
"jsonwebtoken": "^7.0.0",
"lodash": "^4.6.1",
"lusca": "^1.3.0",
"method-override": "^2.3.5",
"mongoose": "^4.1.2",
"morgan": "~1.7.0",
"multer": "^1.3.0",
"multer-gridfs-storage": "^1.2.2",
"ng-google-charts": "^0.1.3",
"passport": "~0.3.0",
"passport-local": "^1.0.0",
"pug": "2.0.0-beta4",
"serve-favicon": "^2.3.0",
"shrink-ray": "^0.1.3",
"sprint-js": "~0.1.0",
"uikit": "^3.0.0-beta.24"
},
"devDependencies": {
"angular-mocks": "~1.6.0",
"autoprefixer": "^6.0.0",
"babel-core": "^6.6.5",
"babel-eslint": "^6.0.4",
"babel-register": "^6.6.5",
"browser-sync": "^2.8.0",
"bs-fullscreen-message": "^1.0.0",
"babel-plugin-transform-class-properties": "^6.6.0",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-preset-es2015": "^6.6.0",
"eslint": "^2.12.0",
"del": "^2.0.2",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-env": "^0.4.0",
"gulp-eslint": "^2.0.0",
"gulp-imagemin": "^3.0.1",
"gulp-inject": "^4.0.0",
"gulp-istanbul": "^1.1.1",
"gulp-istanbul-enforcer": "^1.0.3",
"gulp-load-plugins": "^1.0.0-rc.1",
"gulp-mocha": "^2.1.3",
"gulp-node-inspector": "^0.1.0",
"gulp-plumber": "^1.0.1",
"gulp-protractor": "^3.0.0",
"gulp-rev": "^7.0.0",
"gulp-rev-replace": "^0.4.2",
"gulp-sort": "^2.0.0",
"gulp-sourcemaps": "^1.5.2",
"gulp-util": "^3.0.5",
"gulp-watch": "^4.3.5",
"gulp-stylint": "^3.0.0",
"grunt": "^1.0.1",
"grunt-build-control": "^0.7.0",
"isparta": "^4.0.0",
"nodemon": "^1.3.7",
"run-sequence": "^1.1.0",
"lazypipe": "^1.0.1",
"webpack": "^1.12.14",
"webpack-dev-middleware": "^1.5.1",
"webpack-stream": "^3.2.0",
"extract-text-webpack-plugin": "^1.0.1",
"html-webpack-plugin": "^2.16.0",
"html-webpack-harddisk-plugin": "~0.0.2",
"pug-html-loader": "^1.0.8",
"awesome-typescript-loader": "0.17.0",
"ng-annotate-loader": "~0.1.0",
"babel-loader": "^6.2.4",
"css-loader": "^0.24.0",
"file-loader": "^0.9.0",
"imports-loader": "^0.6.5",
"isparta-instrumenter-loader": "^1.0.0",
"isparta-loader": "^2.0.0",
"istanbul-instrumenter-loader": "^0.2.0",
"null-loader": "^0.1.1",
"postcss-loader": "^0.11.1",
"raw-loader": "^0.5.1",
"style-loader": "^0.13.0",
"node-sass": "^3.8.0",
"sass-loader": "^4.0.1",
"karma-webpack": "^1.7.0",
"through2": "^2.0.1",
"open": "~0.0.4",
"istanbul": "1.1.0-alpha.1",
"chai": "^3.2.0",
"sinon": "^1.16.1",
"chai-as-promised": "^5.1.0",
"chai-things": "^0.2.0",
"karma": "~0.13.3",
"karma-firefox-launcher": "^1.0.0",
"karma-script-launcher": "^1.0.0",
"karma-coverage": "^1.0.0",
"karma-chrome-launcher": "^2.0.0",
"karma-phantomjs-launcher": "~1.0.0",
"karma-spec-reporter": "~0.0.20",
"karma-sourcemap-loader": "~0.3.7",
"sinon-chai": "^2.8.0",
"mocha": "^3.0.2",
"jasmine-core": "^2.3.4",
"karma-jasmine": "^1.0.2",
"jasmine-spec-reporter": "^2.4.0",
"phantomjs-prebuilt": "^2.1.4",
"proxyquire": "^1.0.1",
"strip-ansi": "^3.0.1",
"supertest": "^1.1.0"
},
"engines": {
"node": "6.2.2",
"npm": "3.9.5"
},
"scripts": {
"test": "gulp test",
"update-webdriver": "node node_modules/protractor/bin/webdriver-manager update",
"start": "node server"
},
"private": true
}
And this is the logs when deploying:
Warning: remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NPM_CONFIG_PRODUCTION=true
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 6.2.2
remote: engines.npm (package.json): 3.9.5
remote:
remote: Resolving node version 6.2.2...
remote: Downloading and installing node 6.2.2...
remote: npm 3.9.5 already installed with node
remote:
remote: -----> Restoring cache
remote: Skipping cache restore (new-signature)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json)
remote:
remote: > [email protected] install /tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/iltorb
remote: > node-pre-gyp install --fallback-to-build
remote:
remote: [iltorb] Success: "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/iltorb/build/bindings/iltorb.node" is installed via remote
remote:
remote: > [email protected] install /tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/node-zopfli
remote: > node-pre-gyp install --fallback-to-build
remote:
remote: node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v48-linux-x64.tar.gz
remote: node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v48 ABI) (falling back to source compile with node-gyp)
remote: make: Entering directory '/tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/node-zopfli/build'
remote: CXX(target) Release/obj.target/zopfli/src/zopfli-binding.o
remote: CXX(target) Release/obj.target/zopfli/src/png/zopflipng.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/blocksplitter.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/cache.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/deflate.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/gzip_container.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/hash.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/katajainen.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/lz77.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/squeeze.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/tree.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/util.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/zlib_container.o
remote: CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/zopfli_lib.o
remote: CXX(target) Release/obj.target/zopfli/zopfli/src/zopflipng/zopflipng_lib.o
remote: CXX(target) Release/obj.target/zopfli/zopfli/src/zopflipng/lodepng/lodepng.o
remote: CXX(target) Release/obj.target/zopfli/zopfli/src/zopflipng/lodepng/lodepng_util.o
remote: SOLINK_MODULE(target) Release/obj.target/zopfli.node
remote: COPY Release/zopfli.node
remote: COPY /tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/node-zopfli/lib/binding/node-v48-linux-x64/zopfli.node
remote: TOUCH Release/obj.target/action_after_build.stamp
remote: make: Leaving directory '/tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/node-zopfli/build'
remote:
remote: > [email protected] install /tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/java
remote: > node-gyp rebuild
remote:
remote: [node-java] Error: not found: javac
remote: gyp: Call to 'node findJavaHome.js' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
remote: gyp ERR! configure error
remote: gyp ERR! stack Error: `gyp` failed with exit code: 1
remote: gyp ERR! stack at ChildProcess.onCpExit (/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
remote: gyp ERR! stack at emitTwo (events.js:106:13)
remote: gyp ERR! stack at ChildProcess.emit (events.js:191:7)
remote: gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
remote: gyp ERR! System Linux 3.13.0-128-generic
remote: gyp ERR! command "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.heroku/node/bin/node" "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
remote: gyp ERR! cwd /tmp/build_2beaa787f71f40bc41e528a14b9c399c/node_modules/java
remote: gyp ERR! node -v v6.2.2
remote: gyp ERR! node-gyp -v v3.3.1
remote: gyp ERR! not ok
remote: [email protected] /tmp/build_2beaa787f71f40bc41e528a14b9c399c
remote: ├── [email protected]
remote: ...
remote: ├── [email protected]
remote: └── [email protected]
remote:
remote: npm ERR! Linux 3.13.0-128-generic
remote: npm ERR! argv "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.heroku/node/bin/node" "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_2beaa787f71f40bc41e528a14b9c399c/.npmrc"
remote: npm ERR! node v6.2.2
remote: npm ERR! npm v3.9.5
remote: npm ERR! code ELIFECYCLE
remote:
remote: npm ERR! [email protected] install: `node-gyp rebuild`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
remote: npm ERR! Make sure you have the latest version of node.js and npm installed.
remote: npm ERR! If you do, this is most likely a problem with the java package,
remote: npm ERR! not with npm itself.
remote: npm ERR! Tell the author that this fails on your system:
remote: npm ERR! node-gyp rebuild
remote: npm ERR! You can get information on how to open an issue for this project with:
remote: npm ERR! npm bugs java
remote: npm ERR! Or if that isn't available, you can get their info via:
remote: npm ERR! npm owner ls java
remote: npm ERR! There is likely additional logging output above.
remote:
remote: npm ERR! Please include the following file with any support request:
remote: npm ERR! /tmp/build_2beaa787f71f40bc41e528a14b9c399c/npm-debug.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: Verifying deploy....
remote:
remote: ! Push rejected to tachology.
remote:
To https://git.heroku.com/tachology.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/tachology.git'
Use --force to continue.
Aborted due to warnings.
Upvotes: 3
Views: 883
Reputation: 387
It seems that your node-gyp requires java to be built correctly. The thing with Heroku's architecture is that it only provides you what you specify/need. Right now I don't think Heroku understands that it needs a JVM to run your application. So you should provide a buildpack. A build pack put very simply is a set of rules telling Heroku what to set-up, install and build. There is a buildpack for JVM called heroku/jvm
.
So, what you have to do is add this to your application through the dashboard or your CLI via heroku buildpacks:add heroku/jvm
.
There is one more thing to do. Since your app requires javac at build time itself, we should pull up the build order for java/jvm . So in that case you should probably do heroku buildpacks:add --index 1 heroku/jvm
. This puts the JVM buildpack at position 1 and pushes every other buildpack down the order.
Now when the app starts building, it first sets up the JVM (thus enabling javac for your instance) and then runs the NodeJS build. This build will now pick up the javac from the current instance and build accordingly.
Ref: Mulitple Buildpacks in Heroku
Upvotes: 4