Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku does not read node version

I have a Node project that I want to host on Heroku. I have explicitly defined node and npm versions in my package.json (located in the root directory), which looks like this:

{
  "name": "*********",
  "version": "0.0.0",
  "private": true,
  "engines": {
    "node": "0.12.x",
    "npm": "2.5.x"
  },
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "^1.13.3",
    ...
}

However, when I try to push the app to heroku

git push heroku master 

Heroku tries to build the app, but it seems like it's not able to read the node and npm versions. Here is the response I get.

remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:         
remote:        Resolving node version (latest stable) via semver.io...
remote:        Downloading and installing node 4.2.1...
remote:        Using default npm version: 2.14.7

Why does heroku not read the node and npm version from package.json?

like image 583
nusic Avatar asked Oct 28 '15 10:10

nusic


People also ask

What version of Node does Heroku support?

Since Heroku is based on a standard Ubuntu Linux stack, you can run most Node versions ( >= 0.10. 0 ) on the platform.

Does Heroku run npm install?

Run the npm install command in your local app directory to install the dependencies that you declared in your package. json file. Start your app locally using the heroku local command, which is installed as part of the Heroku CLI.


1 Answers

@rdegges was right that the package.json wasn't correctly committed to Heroku. So just following the Heroku instructions didn't work for me for some reason. Here is what I had to do in order to make it work.

git clone <my git project>
heroku create <app name>

#remove package.json
mv package.json tmp_package.json
git add package.json
git commit -m "removed package.json"

#re-add package.json
mv tmp_package.json package.json
git add package.json
git commit -m "re-added package.json"

git push heroku master
like image 141
nusic Avatar answered Sep 18 '22 08:09

nusic