我正在本书中进行演练,在顶部构建一个带有Angular 2的Rails API应用程序。 Github
按照Angular For Rails开发人员手册中的说明使用两个buildpack。
heroku buildpacks:add https://github.com/jasonswett/heroku-buildpack-nodejs
heroku buildpacks:add heroku/ruby
我的所有更新都已签入。当我git push heroku master
时,我收到以下错误打印输出
remote: Running heroku-postbuild
remote:
remote: > author-wizard@0.0.0 heroku-postbuild /tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client
remote: > ng build
remote:
remote: Could not start watchman; falling back to NodeWatcher for file system events.
remote: Visit http://ember-cli.com/user-guide/#watchman for more info.
33% building modules 19events.js:160
remote: throw er; // Unhandled 'error' event
remote: ^
remote:
remote: Error: This socket is closed
remote: at Socket._writeGeneric (net.js:673:19)
remote: at Socket._write (net.js:724:8)
remote: at doWrite (_stream_writable.js:307:12)
remote: at writeOrBuffer (_stream_writable.js:293:5)
remote: at Socket.Writable.write (_stream_writable.js:220:11)
remote: at Socket.write (net.js:651:40)
remote: at Socket.process.stderr.write (/tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client/node_modules/angular-c
li/lib/cli/index.js:30:27)
remote: at Console.warn (console.js:51:16)
remote: at printErrorAndExit (/tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client/node_modules/awesome-typescript-
loader/node_modules/source-map-support/source-map-support.js:406:11)
remote: at process.emit (/tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client/node_modules/awesome-typescript-loade
r/node_modules/source-map-support/source-map-support.js:419:16)
remote: at process._fatalException (bootstrap_node.js:296:26)
remote:
remote: npm ERR! Linux 3.13.0-100-generic
remote: npm ERR! argv "/tmp/build_6cac525cd409f823d4d8849a2cb7eba2/client/.heroku/node/bin/node" "/tmp/build_6cac525c
d409f823d4d8849a2cb7eba2/client/.heroku/node/bin/npm" "run" "heroku-postbuild" "--if-present"
remote: npm ERR! node v6.6.0
remote: npm ERR! npm v3.10.3
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! author-wizard@0.0.0 heroku-postbuild: `ng build`
remote: npm ERR! Exit status 7
remote: npm ERR!
remote: npm ERR! Failed at the author-wizard@0.0.0 heroku-postbuild script 'ng build'.
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 author-wizard package,
remote: npm ERR! not with npm itself.
remote: npm ERR! Tell the author that this fails on your system:
remote: npm ERR! ng build
remote: npm ERR! You can get information on how to open an issue for this project with:
remote: npm ERR! npm bugs author-wizard
remote: npm ERR! Or if that isn't available, you can get their info via:
remote: npm ERR! npm owner ls author-wizard
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_6cac525cd409f823d4d8849a2cb7eba2/client/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 evening-castle-95407.
remote:
To https://git.heroku.com/evening-castle-95407.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/evening-castle-95407.git'
我的package.json看起来像这样:
{
"name": "author-wizard",
"version": "0.0.0",
"engines": {
"node": "6.6.0",
"npm": "3.10.3"
},
"license": "MIT",
"angular-cli": {},
"scripts": {
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"preinstall": "npm install -g node-gyp",
"heroku-postbuild": "ng build"
},
"private": true,
"dependencies": {
"@angular/common": "~2.0.0",
"@angular/compiler": "~2.0.0",
"@angular/core": "~2.0.0",
"@angular/forms": "~2.0.0",
"@angular/http": "~2.0.0",
"@angular/platform-browser": "~2.0.0",
"@angular/platform-browser-dynamic": "~2.0.0",
"@angular/router": "~3.0.0",
"core-js": "^2.4.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23",
"@types/jasmine": "^2.2.30",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.17",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2"
},
"devDependencies": {
}
}
我在教程中添加的唯一内容是引擎定义,但是如果我在部署时遇到问题,Heroku就说要将其放入(以匹配我的本地版本)。
"引擎":{ " node":" 6.6.0", " npm":" 3.10.3" },
有关如何推进部署的任何提示都很棒。谢谢!
更新 从
更改了package.json"heroku-postbuild": "ng build"
到
"heroku-postbuild": "ng build -prod"
它部署得很好。还有其他问题w Uglifier gem,但这个问题得到了解决。谢谢@jasonswett