Angular 2/Nodejs 部署到 heroku 错误 heroku-postbuild: `ng build`
Posted
技术标签:
【中文标题】Angular 2/Nodejs 部署到 heroku 错误 heroku-postbuild: `ng build`【英文标题】:Angular 2/Nodejs deploy to heroku error heroku-postbuild: `ng build` 【发布时间】:2018-03-06 11:24:22 【问题描述】:我想将 angular2/nodejs 应用程序部署到 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 -产品”
我的 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】:您没有附加整个 package.json 文件,但 Heroku 似乎不知道“ng build”命令。
确保将 angular-cli 放在 package.json 的依赖项部分,而不是 devDependencies。
【讨论】:
以上是关于Angular 2/Nodejs 部署到 heroku 错误 heroku-postbuild: `ng build`的主要内容,如果未能解决你的问题,请参考以下文章
URL 找不到 Angular2 404:http://localhost/WebApi2/api/hero
Angular 2 Tour of Heroes:按名称过滤英雄