0

Although I checked other posts on the net and Stackoverflow I couldn't figure it out. I am tryin to deploy my app to Heroku. However, I have been facing an issue about parsing json file. Json seems proper and applied these suggestions like 'heroku' does not appear to be a git repository

Or heroku error: Expected another key-value pair

Or Heroku app won't deploy parse error: Expected another key-value pair at line 10, column 3 node.js

You can see my jason as:

{
  "name": "signup",
  "version": "1.0.0",
  "description": "Newsletter mailing",
  "main": "app.js",
  "scripts": {
    "start": "node app.js",
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "ng build",
    "heroku-postbuild": "ng build --prod"
  },
  "dependencies": {
    "@mailchimp/mailchimp_marketing": "^3.0.66",
    "body-parser": "^1.19.0",
    "express": "^4.17.1",
    "hyperline": "^1.2.0",
    "nodemon": "^2.0.12"
  },
  "author": "",
  "license": "ISC",
  "engines": {
    "node": "14.15.3",
    "npm": "6.14.9"
  },
}

Also you can see error as: Hyperterminal screen after git push heroku commad

What do you think? Thank you

torek
  • 448,244
  • 59
  • 642
  • 775

1 Answers1

0

This has nothing to do with Git: when using Heroku, Git is just a messenger, delivering "packages" as it were with your source files. Heroku then opens the packages (in this case failing while reading the package file!) and processes their contents and produces its own messages, which Git relays back to you.

The Heroku text is everything prefixed with the word remote. In this case you get, among other items, these lines:

remote: parse error: Expected another key-value pair at line 22, column 1
remote:  !     Unable to parse package.json

The parse error and subsequent line are messages from Heroku: Git has prefixed them with the word remote to tell you I, Git, am not saying this; I am just relaying something someone else said here.

Now, there is an obvious1 error in your JSON file, but it's not actually on line 22, it's on line 24 (or in the missing text between line 24 and line 25):

 21   "engines": {
 22     "node": "14.15.3",
 23     "npm": "6.14.9"
 24   },

See how line 24 ends with a comma? This means there must be more JSON below—but the next thing is just a final closing brace, which means line 24 should end without a comma.

(With luck, my retyping of your Heroku messages did not introduce any errors. This may not be the only problem, but it should get you past the failure to parse the JSON file.)


1Obvious once you know, anyway. JSON is very strict about comma as separator, not terminator.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
torek
  • 448,244
  • 59
  • 642
  • 775
  • Thank you @torek for your help and will keep in mind when I ask questions next time. Also, appreciate for detailed explanation but although I deleted comma after } at line 24. The issue still remains and output didn't change. – Tonyukuk Oct 12 '21 at 07:52
  • There might be some other issue, but certainly the JSON text you posted became readable after I trimmed the stray comma. Whether Heroku would be happy with it, I don't know. – torek Oct 12 '21 at 08:00
  • It seems so, I will check them. But not sure how to handle it. – Tonyukuk Oct 12 '21 at 09:59