我使用angular-cli创建了angular2应用程序。
接下来我想构建它并部署到heroku,所以我更新了package.json
文件中的脚本部分:
"scripts": {
"heroku-prebuild": "npm install angular-cli@1.0.0-beta.17",
"postinstall": "./node_modules/.bin/ng build --dev"
}
当我在本地计算机应用程序版本上运行npm install
时没有错误。同样的,当我使用bitbucket管道运行它时,但是当我尝试将它部署到heroku构建失败时。
这是消息的一部分:
0ms additional asset processing
1922ms chunk asset optimization
94% asset optimizationError in bail mode: [default] /tmp/build_c10a47380f869e4f82169d259a47dab7/src/app/app.component.ts:5:12
remote: Cannot find name 'require'.
remote:
remote: npm ERR! Linux 3.13.0-95-generic
remote: npm ERR! argv "/tmp/build_c10a47380f869e4f82169d259a47dab7/.heroku/node/bin/node" "/tmp/build_c10a47380f869e4f82169d259a47dab7/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_c10a47380f869e4f82169d259a47dab7/.npmrc"
remote: npm ERR! node v6.1.0
remote: npm ERR! npm v3.8.9
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! xxxxxx@0.0.0 postinstall: `ng build --dev`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the xxxxxx@0.0.0 postinstall script 'ng build --dev'.
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 xxxxxx 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 --dev
remote: npm ERR! You can get information on how to open an issue for this project with:
remote: npm ERR! npm bugs xxxxxx
remote: npm ERR! Or if that isn't available, you can get their info via:
remote: npm ERR! npm owner ls xxxxxx
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_c10a47380f869e4f82169d259a47dab7/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 xxxxxx.
remote:
你知道为什么heroku不能构建angular2应用程序吗? 如何解决这个问题?