Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm ERR! Failed to parse package.json data. #2930

Closed
KenKennef opened this issue Mar 4, 2016 · 26 comments
Closed

npm ERR! Failed to parse package.json data. #2930

KenKennef opened this issue Mar 4, 2016 · 26 comments
Labels

Comments

@KenKennef
Copy link

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
@KenKennef KenKennef changed the title Get this when trying npm install express npm ERR! Failed to parse package.json data. Mar 4, 2016
@KenKennef
Copy link
Author

npm-debug.txt

@tunniclm
Copy link
Contributor

tunniclm commented Mar 4, 2016

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.

@KenKennef
Copy link
Author

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

  • Kenneth

@Knighton910
Copy link

+1 @tunniclm

npm cache clean

@jclwong
Copy link

jclwong commented Oct 26, 2016

@tunniclm - Thanks

@robaxelsen
Copy link

+1 @tunniclm - thanks a lot!

@chikehenderson
Copy link

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

@chikehenderson
Copy link

well something worked... :/

@davidobi023
Copy link

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 npm@3.10.10
3 info using node@v6.11.0
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 ]

@davidobi023
Copy link

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

@davidobi023
Copy link

davidobi023 commented Aug 1, 2017

{
"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"
}
}

@jimmyolo
Copy link

jimmyolo commented Aug 1, 2017

missing a comma ,
At line 7

@davidobi023
Copy link

Hi victor. issue resolved already. many thanks

@chikehenderson
Copy link

chikehenderson commented Aug 2, 2017 via email

@wilsonj19
Copy link

npm cache clean
excellent tnks so much

@chikehenderson
Copy link

chikehenderson commented Oct 19, 2017 via email

@imfeng
Copy link

imfeng commented Dec 16, 2017

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

@mahsabehbahani
Copy link

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

@wesleytodd
Copy link
Member

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

@mahsabehbahani
Copy link

mahsabehbahani commented Feb 5, 2018

@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'

@wesleytodd
Copy link
Member

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.

@mahsabehbahani
Copy link

@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

@wesleytodd
Copy link
Member

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

@mahsa-pb
Copy link

mahsa-pb commented Feb 6, 2018

@wesleytodd
yes , i post this in the express gitter

@AdiBev
Copy link

AdiBev commented Mar 21, 2018

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"
  }
}

@dougwilson
Copy link
Contributor

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 :)

@expressjs expressjs locked as resolved and limited conversation to collaborators Mar 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests