What needs to change in this package.json file to work with npm 0.3.0?

前端 未结 6 542
时光取名叫无心
时光取名叫无心 2021-01-04 23:33

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 actua         


        
相关标签:
6条回答
  • 2021-01-04 23:52

    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": "bob@embed.ly"
      , "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"
      }
    }
    
    0 讨论(0)
  • 2021-01-04 23:53

    In addition to @Hans Engel's answer use npm help json to get the specification of what should be in the package.json file

    0 讨论(0)
  • 2021-01-05 00:03

    I have been through this problem and in my case it was just that in place of comma(,). I have used dot(.). You can simply open it up in any JSON validator and it will help you up. One of the JSON validator's link is as follows . http://www.bodurov.com/JsonFormatter/

    0 讨论(0)
  • 2021-01-05 00:07

    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!

    0 讨论(0)
  • 2021-01-05 00:13

    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.

    0 讨论(0)
  • 2021-01-05 00:17

    I also got the same error message, first run npm package.json to check errors in package.json file, if not then run npm cache clean.

    0 讨论(0)
提交回复
热议问题