Express: npm ERR! Failed to parse package.json data.

Created on 4 Mar 2016  ·  26Comments  ·  Source: expressjs/express

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\KennethVoss\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.3.1
npm ERR! npm  v3.8.0
npm ERR! file C:\Users\KennethVoss\AppData\Roaming\npm-cache\inherits\2.0.1\package\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! No data, empty input at 1:1
npm ERR!
npm ERR! ^
npm ERR! File: C:\Users\KennethVoss\AppData\Roaming\npm-cache\inherits\2.0.1\package\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse
question

Most helpful comment

Can you check the contents of file C:\Users\KennethVoss\AppData\Roaming\npm-cache\inherits\2.0.1\package\package.json? Is it actually empty, as the error is suggesting? It shouldn't be!

You may want to try npm cache clean and retry the install to see that helps.

All 26 comments

Can you check the contents of file C:\Users\KennethVoss\AppData\Roaming\npm-cache\inherits\2.0.1\package\package.json? Is it actually empty, as the error is suggesting? It shouldn't be!

You may want to try npm cache clean and retry the install to see that helps.

Thanks tunniclm - the cache clean solved it! Thank you for a quick reply :)

  • Kenneth

+1 @tunniclm

npm cache clean

@tunniclm - Thanks

+1 @tunniclm - thanks a lot!

"[ ..............] | fetchMetadata: sill mapToRegistry uri https://registry.n.." - I hope this works for me..

well something worked... :/

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose stack Error: Failed to parse json
4 verbose stack Unexpected token 'b' at 8:6
4 verbose stack "build": "electron-packager . mysample"
4 verbose stack ^
4 verbose stack at parseError (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:390:11)
4 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:79:23)
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:48:5
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16
4 verbose stack at tryToString (fs.js:456:3)
4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:443:12)
5 verbose cwd C:\Users\David\Desktop\tut\mysample
6 error Windows_NT 10.0.10586
7 error argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "build"
8 error node v6.11.0
9 error npm v3.10.10
10 error file C:\Users\David\Desktop\tut\mysample\package.json
11 error code EJSONPARSE
12 error Failed to parse json
12 error Unexpected token 'b' at 8:6
12 error "build": "electron-packager . mysample"
12 error ^
13 error File: C:\Users\David\Desktop\tut\mysample\package.json
14 error Failed to parse package.json data.
14 error package.json must be actual JSON, not just JavaScript.
14 error
14 error This is not a bug in npm.
14 error Tell the package author to fix their package.json file. JSON.parse
15 verbose exit [ 1, true ]

Urgent help please, tried the "npm cache clean" command..trying to build a sample project using electron.. Also my package.json content is contained below

{
"name": "tut",
"version": "0.1.0",
"description": "A sample training on using node js ",
"main": "main.js",
"scripts": {
"start": "electron index.js"
"package": "",
"build": "electron-packager . mysample"
},
"author": "namegoeshere xyz@gmail.com",
"license": "MIT",
"devDependencies": {
"asar": "^0.13.0",
"electron-packager": "^8.7.2"
}
}

missing a comma ,
At line 7

Hi victor. issue resolved already. many thanks

Did you npm install..

On Tue, Aug 1, 2017 at 6:57 PM, davidobi023 notifications@github.com
wrote:

Urgent help please, tried the "npm cache clean" command..trying to build a
sample project using electron.. Also my package.json content is contained
below


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/expressjs/express/issues/2930#issuecomment-319464014,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGDyiEc-0kh_Z4_NUEHp9bAiDEA6zfULks5sT3UkgaJpZM4HpM-n
.

npm cache clean
excellent tnks so much

no problems.. ;)

Kind Regards,

C
https://www.google.co.uk/search?q=Metaphysicist&spell=1&sa=X&ved=0ahUKEwjf8vvvkvPWAhXBcBoKHb1nDAIQvwUIJSgAhike
Henderson,Meta-physicist,Computer Scientist,

Information Technology Solutions Expert
Email: chike.[email protected]
Website: http://www.sprintandcrash.com

On Thu, Oct 19, 2017 at 6:25 PM, wilsonj19 notifications@github.com wrote:

npm cache clean
excellent tnks so much


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/expressjs/express/issues/2930#issuecomment-337995447,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGDyiCXf-Nzt8FjrloHR4t4UevIpj6FKks5st5Q2gaJpZM4HpM-n
.

I just minify "package.json" and it worked !

when i want to run my react app with these commands:
npm run build
npm run start

i get these errors:
npm ERR! code EJSONPARSE
npm ERR! failed to parse json
npm ERR! unexpected token b in JSON at position 117 while parsing near '...
"scripts": <
build: "webpack ",
...'
npm ERR! failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR! tell the package author to fix their package.json file. JSON.parse

my package.json code is:

{
"name": "reactjs",
"version": "1.0.0",
"description": "",
"main": "index.js",

"scripts": {
build: "webpack",
start: "webpack-dev-server"
}

"author": "",
"license": "ISC",

"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0"
},

"devDependencies": {

"babel-core": "^6.26.0",

"babel-loader": "^7.1.2",

"babel-preset-react": "^6.24.1",

"html-webpack-plugin": "^2.30.1",

"webpack": "^3.10.0",

"webpack-dev-server": "^2.11.1"

}

}

npm cache clear dosn't affect

@mahsabehbahani You are missing quotes around your scripts. It is json not javascript, it requires the "".

@wesleytodd thanks for quick answer,
i fixed this but i get error yet with this change:

npm ERR! unexpected string in JSON at position 174 while parsing '{
"name": "reactjs",
"version": "1'

No worries :) I was talking about this section:

"scripts": {
build: "webpack",
start: "webpack-dev-server"
}

It should read:

"scripts": {
"build": "webpack",
"start": "webpack-dev-server"
}

But your new error seems different. It would be helpful if you posted the exact and full output from your terminal using a code block formatting with three back tick characters (`). You can check the comment with the "preview" tab in github to make sure it looks like you see it in the terminal.

@wesleytodd
This is exact output:
```
npm ERR! file E:\reactJS\package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected string in JSON at position 174 while parsing '{
npm ERR!
npm ERR! "name": "reactjs",
npm ERR!
npm ERR! "version": "1'
npm ERR! File: E:\reactJS\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! Tell the package author to fix their package.json file. JSON.parse

Yep, as the error message says, you have invalid json in that file. I am sorry but this is not the right place to be doing support like this. Can you please post this on stackoverflow or in the express gitter instead of continuing the conversation here?

https://gitter.im/expressjs/express

@wesleytodd
yes , i post this in the express gitter

Hi guys, I am having the same problem as mahsa-pb. I have validated my json file and it is fine so no idea what is wrong with my json file. Please help me thank you.

     {
  "name": "React-2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "npm run build",
   "build": "webpack -d && webpack-dev-server --content-base src/ --inline --hot --port 1234"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0"
  },
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.4",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "webpack": "^3.11.0",
    "webpack-dev-server": "^3.1.1"
  }
}

Hi @AdiBev paste your JSON into a validator site like https://jsonformatter.curiousconcept.com/ 👍
image

For support and discussion, please come over to https://gitter.im/expressjs/express and we can let this 2 year old issue rest :)

Was this page helpful?
0 / 5 - 0 ratings