Ahmed Mohamed Abdo
Ahmed Mohamed Abdo

Reputation: 97

How to fix NPM EJSONParse in this package.json file?

After I prepared for auto scripts and installing few packages to automate my tasks, I got the following error:

npm ERR! file C:\Users\windw\Desktop\bootstrap4\package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 455 while parsing '{
npm ERR! JSON.parse   "name": "confusion",
npm ERR! JSON.parse   "version": '
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

Below is my package.json file

{
  "name": "confusion",
  "version": "1.0.0",
  "description": "This is a website for Ristorante Con Fusion",
  "main": "index.html",
  "scripts": {
    "start": "npm run watch:all",
    "test": "echo \"Error: no test specified\" && exit 1",
    "lite": "lite-server",
    "scss": "node-sass -o css/ css/",
    "watch:scss": "onchange \"css/*.scss\" -- npm run scss",
    "watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\""
    "clean": "rimraf dist",
    "copyfonts": "copyfiles -f node_modules/font-awesome/fonts/* dist/fonts",
    "imagemin": "imagemin img/* --out-dir='dist/img'",
    "usemin": "usemin contactus.html -d dist --htmlmin -o dist/contactus.html && usemin aboutus.html -d dist --htmlmin -o dist/aboutus.html && usemin index.html -d dist --htmlmin -o dist/index.html",
    "build": "npm run clean && npm run imagemin && npm run copyfonts && npm run usemin"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "cssmin": "^0.4.3",
    "htmlmin": "0.0.7",
    "lite-server": "^2.3.0",
    "node-sass": "^4.7.2",
    "onchange": "^6.1.0",
    "parallelshell": "^3.0.2",
    "rimraf": "^2.6.2",
    "uglifyjs": "^2.4.11",
    "usemin-cli": "^0.5.1"
  },
  "dependencies": {
    "bootstrap": "^4.3.1",
    "bootstrap-social": "5.1.1",
    "font-awesome": "4.7.0",
    "jquery": "^3.4.1",
    "popper.js": "1.12.9"
  }
}

How can I fix the NPM EJSONParse error?

Upvotes: 5

Views: 16315

Answers (2)

Md. Abu Sayed
Md. Abu Sayed

Reputation: 2486

This error occurred when you are somehow missing "," comma. and when you use comma in last line if not required also it happens. If this issue showed, you need to review your pakage.json file.

Upvotes: 1

madebydavid
madebydavid

Reputation: 6527

You are missing a comma at the end of the 12th line in your package.json file.

Presently it looks like this:

"watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\""

It should look like this:

"watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\"",

Note the comma at the end of the line.

Upvotes: 2

Related Questions