json – Error uploading a NodeJS application on Heroku

Question:

When executing the command:

git push heroku master

LOG:

-----> Node.js app detected

parse error: Unfinished string

!     Unable to parse package.json

-----> Build failed



We're sorry this build is failing! You can troubleshoot common issues here:

https://devcenter.heroku.com/articles/troubleshooting-node-deploys

If you're stuck, please submit a ticket so we can help:

https://help.heroku.com/

Love,

Heroku


!     Push rejected, failed to compile Node.js app.

!     Push failed

Package.json file

{
  "name": "application-name",
  "version": "0.0.1",
  "description": "Contatos com NodeJS",
  "engines": {
    "node": "6.10.2",
    "npm": "3.10.10"
  },
  "scripts": {
    "start": "node app.js",
  },
  "dependencies": {
    "bcrypt-nodejs": "0.0.3",
    "body-parser": "~1.0.0",
    "cookie-parser": "~1.0.1",
    "debug": "~0.7.4",
    "express": "~4.0.0",
    "express-flash": "0.0.2",
    "express-load": "^1.1.15",
    "express-session": "latest",
    "express-validator": "^3.2.0",
    "jade": "~1.3.0",
    "moment": "^2.18.1",
    "mongoose": "^4.9.6",
    "morgan": "~1.0.0",
    "nodemailer": "^4.0.1",
    "static-favicon": "~1.0.0"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/mariojbe/contatos_NodeJS"
  },
  "keywords": [
    "node",
    "heroku",
    "express"
  ],
  "license": "MIT"
}

Answer:

The error returned is very clear.

Unable to parse package.json

That is, the package.json file is invalid.

Look at the scripts attribute, it has the start attribute, its value and then a comma, remove the comma.

You can always make use of some tools to validate this. I used JSONLint .

"scripts": {
   "start": "node app.js"
},

complete file

{
  "name": "application-name",
  "version": "0.0.1",
  "description": "Contatos com NodeJS",
  "engines": {
    "node": "6.10.2",
    "npm": "3.10.10"
  },
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "bcrypt-nodejs": "0.0.3",
    "body-parser": "~1.0.0",
    "cookie-parser": "~1.0.1",
    "debug": "~0.7.4",
    "express": "~4.0.0",
    "express-flash": "0.0.2",
    "express-load": "^1.1.15",
    "express-session": "latest",
    "express-validator": "^3.2.0",
    "jade": "~1.3.0",
    "moment": "^2.18.1",
    "mongoose": "^4.9.6",
    "morgan": "~1.0.0",
    "nodemailer": "^4.0.1",
    "static-favicon": "~1.0.0"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/mariojbe/contatos_NodeJS"
  },
  "keywords": [
    "node",
    "heroku",
    "express"
  ],
  "license": "MIT"
}
Scroll to Top