[英]Failed deployment with Heroku (npm java)
I am trying to deploy my app through Heroku, which is working perfectly on localhost. 我正在尝试通过Heroku部署我的应用程序,它在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 .
尽管我在本地主机上安装java模块时遇到了一些麻烦,但由于这篇文章,我终于做到了: 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. 现在,我在将应用程序部署到Heroku上时遇到了同样的错误,但是现在我无法修复它。 I set even the Java Buildpack, just in case, but it didnt help.
我设置了Java Buildpack,以防万一,但这并没有帮助。
I hope someone could help me! 我希望有人可以帮助我!
This is my package.json: 这是我的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: > iltorb@1.3.6 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: > node-zopfli@1.4.0 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 node-zopfli@1.4.0 and node@6.2.2 (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: > java@0.8.0 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: tachology@0.0.0 /tmp/build_2beaa787f71f40bc41e528a14b9c399c
remote: ├── angular@1.6.6
remote: ...
remote: ├── sprint-js@0.1.0
remote: └── uikit@3.0.0-beta.30
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! java@0.8.0 install: `node-gyp rebuild`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the java@0.8.0 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.
It seems that your node-gyp requires java to be built correctly. 看来您的node-gyp需要正确构建Java。 The thing with Heroku's architecture is that it only provides you what you specify/need.
Heroku架构的特点是它仅提供您指定/需要的内容。 Right now I don't think Heroku understands that it needs a JVM to run your application.
现在,我不认为Heroku理解它需要JVM来运行您的应用程序。 So you should provide a buildpack.
因此,您应该提供一个buildpack。 A build pack put very simply is a set of rules telling Heroku what to set-up, install and build.
简而言之,构建包就是一组规则,它告诉Heroku要设置,安装和构建的内容。 There is a buildpack for JVM called
heroku/jvm
. 有一个名为
heroku/jvm
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
. 因此,您要做的就是通过仪表板或CLI通过
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 .
由于您的应用程序本身在构建时就需要javac,因此我们应该调高java / jvm的构建顺序。 So in that case you should probably do
heroku buildpacks:add --index 1 heroku/jvm
. 因此,在这种情况下,您可能应该执行
heroku buildpacks:add --index 1 heroku/jvm
。 This puts the JVM buildpack at position 1 and pushes every other buildpack down the order. 这会将JVM buildpack置于位置1,并将其他所有buildpack推入顺序。
Now when the app starts building, it first sets up the JVM (thus enabling javac for your instance) and then runs the NodeJS build. 现在,当应用程序开始构建时,它首先设置JVM(从而为您的实例启用javac),然后运行NodeJS构建。 This build will now pick up the javac from the current instance and build accordingly.
现在,此构建将从当前实例中拾取javac并进行相应构建。
Ref: Mulitple Buildpacks in Heroku 参考: Heroku中的Mulitple Buildpacks
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.