需要更改此package.json文件才能使用npm 0.3.0?

fan*_*ncy 9 javascript json package node.js npm

尝试使用lib但收到此错误...

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.
Run Code Online (Sandbox Code Playgroud)

不确定可能需要哪些更改才能使其成为有效的JSON,非常感谢!

Afs*_*ani 16

只是为了完成答案,您只需使用在线JSON验证器来验证您的答案package.json.
我强烈推荐http://jsonlint.com/,粘贴你package.json的textarea并点击Validate按钮,这就是全部!


Jon*_*ier 14

有效的JSON必须包含引号中对象的键和值.用引号括住所有键,这应该会使错误消失.

参考:JSON规范

更新:我为你做了肮脏的工作.如果这解决了,请告诉我.

{ "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"
  }
}
Run Code Online (Sandbox Code Playgroud)

  • 另一个常见的区别是任何字典或数组中的尾随常见.JSON必须没有尾随逗号. (4认同)

Bar*_*run 8

修复/验证package.json的超酷方式:

node package.json

并且您已经验证了json或错误行.

为什么要使用jsonlint,听起来很蹩脚.


Per*_* P. 5

除了@Hans Engel的回答用于npm help json获取package.json文件中应该包含的内容的规范