What needs to change in this package.json file to work with npm 0.3.0?
Solution 1
Valid JSON must have both keys and values of an object in quotes. Surround all of your keys in quotation marks and that should make the error go away.
Reference: JSON spec
Update: I did the dirty work for you. Let me know if this fixes it.
{ "name": "embedly"
, "version": "0.3.2"
, "description": "Embedly client library for node"
, "homepage": "https://github.com/embedly/embedly-node"
, "keywords": []
, "author":
{ "name": "Bob Corsaro"
, "email": "[email protected]"
, "url": "http://www.google.com/profiles/rcorsaro"
}
, "repository":
{ "type": "git"
, "url": "git://github.com/embedly/embedly-node"
}
, "bugs": { "web": "http://github.com/embedly/embedly-node/issues/" }
, "directories":
{ "doc": "./docs"
, "lib": "./lib"
, "test": "./test"
}
, "dependencies": {"hashish": "", "qs": ""}
, "devDependencies": {"vows": ">= 0.5.6"}
, "main": "./lib/embedly.js"
, "scripts": { "test": "vows" }
, "bin":
{ "embedly_oembed": "bin/embedly_oembed.js"
, "embedly_objectify": "bin/embedly_objectify.js"
, "embedly_preview": "bin/embedly_preview.js"
}
}
Solution 2
Just to complete the answer, you can simply use an online JSON validator to validate your package.json
.
I highly recommend http://jsonlint.com/, paste your package.json
in the textarea and click on the Validate button, that's all!
Solution 3
Super cool way to fix / validate the package.json :
node package.json
and you have your json validated or the error line.
Why use jsonlint, sounds pretty lame.
Solution 4
In addition to @Hans Engel's answer use npm help json
to get the specification of what should be in the package.json file
Related videos on Youtube
fancy
Updated on August 02, 2020Comments
-
fancy over 3 years
Trying to use a lib but getting this error...
npm ERR! JSON.parse Failed to parse package.json data. npm ERR! JSON.parse Note that package.json must be actual JSON, not npm ERR! JSON.parse just a JavaScript object. npm ERR! JSON.parse npm ERR! JSON.parse This changed in npm 0.3.0, and is not a bug in npm. npm ERR! JSON.parse Tell the package author to fix their package.json file.
Not sure what changes are likely needed to make it valid JSON, thanks very much!
-
Erik over 10 yearsThe other common difference is the trailing common in any of the dictionaries or arrays. The JSON must not have a trailing comma.
-
Antfish almost 9 yearsThis threw me too as I had to wrap a boolean in quote marks. It was passing on jsonlint.com without the quotes.
-
Barun over 8 yearsAnd I higly recommend my way of validating json objects @afshin Mehrabani