Angular 2 / Nodejs部署到heroku错误heroku-postbuild:`ng build`

时间:2017-09-25 13:09:46

标签: javascript angularjs node.js ubuntu heroku

我想将angular2 / nodejs app部署到heroku。

版本: "节点":" 8.x"," npm":" 3.10.9"

配置完成后,我收到此错误:

> "/tmp/build_a3ccb3e805890c0441cf2241d8620683/.heroku/node/bin/npm"
> "run" "heroku-postbuild" "--if-present"
>     remote: npm ERR! node v8.5.0
>     remote: npm ERR! npm  v3.10.9
>     remote: npm ERR! code ELIFECYCLE
>     remote: npm ERR! lists-book@0.0.1 heroku-postbuild: `ng build`
>     remote: npm ERR! Exit status 1
>     remote: npm ERR! 
>     remote: npm ERR! Failed at the lists-book@0.0.1 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 lists-book 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 lists-book
>     remote: npm ERR! Or if that isn't available, you can get their info via:
>     remote: npm ERR!     npm owner ls lists-book
>     remote: npm ERR! There is likely additional logging output above.

我多次更改此行但仍然出现相同的错误,但它无效:

" heroku-postbuild":" ng build",或" heroku-postbuild":" ng build --env = prod --aot = false",或" heroku-postbuild":" ng build --aot -prod"

部分我的package.json

"angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "node server.js",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor",
    "heroku-postbuild": "ng build",
    "build_prod": "npm run build && browserify -s main dist/main.js > dist/bundle.js && npm run minify",
    "minify": "uglifyjs dist/inline.bundle.js --screw-ie8 --compress --mangle --output dist/inline.bundle.js; uglifyjs dist/main.bundle.js --screw-ie8 --compress --mangle --output dist/main.bundle.js; uglifyjs dist/styles.bundle.js --screw-ie8 --compress --mangle --output dist/styles.bundle.js; uglifyjs dist/polyfills.bundle.js --screw-ie8 --compress --mangle --output dist/polyfills.bundle.js; uglifyjs dist/vendor.bundle.js --screw-ie8 --compress --mangle --output dist/vendor.bundle.js; json-minify src/assets/translations/pl.json > dist/assets/translations/pl.json; json-minify src/assets/translations/en.json > dist/assets/translations/en.json; json-minify src/assets/translations/es.json > dist/assets/translations/es.json"
  }

1 个答案:

答案 0 :(得分:0)

您没有附加整个package.json文件,但是Heroku似乎不知道'ng build'命令。

确保将angular-cli放置在package.json的依赖项部分中,而不是devDependencies。