我正在尝试学习如何将一个Node和Angular应用程序部署到Heroku并且收到错误。
以下是我正在采取的步骤
在GitHub上创建一个空的回购。
部署预创建project,创建一个新的heroku应用。
接下来,我下载并复制预先创建的project中的代码。
然后我将该代码推送到我创建的第一步的空仓库。
然后我回到Heroku并手动部署将我的回购连接到它。
部署时,我得到一个我不知道如何解决的错误。这对我来说很奇怪,因为我有预配置的Heroku应用程序以及完全相同的代码。
> Building dependencies
Installing node modules (package.json)
> mean-contactlist-angular2@0.0.0 postinstall /tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e
> ng build
Cannot read property 'config' of null
TypeError: Cannot read property 'config' of null
at Class.run (/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/node_modules/@angular/cli/tasks/build.js:16:56)
at Class.run (/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/node_modules/@angular/cli/commands/build.js:143:26)
at Class.<anonymous> (/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17)
at process._tickCallback (internal/process/next_tick.js:109:7)
npm ERR! Linux 3.13.0-133-generic
npm ERR! argv "/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/.heroku/node/bin/node" "/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/.npmrc"
npm ERR! node v6.11.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! mean-contactlist-angular2@0.0.0 postinstall: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mean-contactlist-angular2@0.0.0 postinstall script 'ng build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mean-contactlist-angular2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ng build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs mean-contactlist-angular2
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls mean-contactlist-angular2
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/build_00959509bf83606e9586c85b4acd5130/worldofnick-LocalBeats-34154d74169daf6c8cdab1e9e5407bd4e4f9c24e/npm-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
答案 0 :(得分:1)
我今天在部署到Heroku时遇到了这个问题。在package.json中,确保正确地将节点指定为引擎。例如:
"engines": {
"node": "^8.0.0"
},