user3440639
user3440639

Reputation: 185

Deploying Node and Angular to Heroku error

I'm trying to learn how to deploy a Node and Angular app to Heroku and am getting an error.

Here are the steps I'm taking

  1. Create an empty repo on GitHub.

  2. Deploy the pre-create project, which creates a new heroku app.

Next, I download and copy the code that is in the pre-created project.

Then I push that code up to the empty repo I created step 1.

I then go back to Heroku and manually deploy connecting my repo to it.

When deploying I get an error that I don't know how to resolve. This is strange to me since I have the pre-configured Heroku app along with the exact same code.

> Building dependencies
       Installing node modules (package.json)

       > [email protected] 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! [email protected] postinstall: `ng build`
       npm ERR! Exit status 1
       npm ERR!
       npm ERR! Failed at the [email protected] 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

Upvotes: 1

Views: 612

Answers (1)

veekas ashoka
veekas ashoka

Reputation: 446

I ran into this problem while deploying to Heroku today. In your package.json, make sure you are correctly specifying node as your engine. Example:

"engines": {
  "node": "^8.0.0"
},

Upvotes: 1

Related Questions