简体   繁体   English

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

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

Trying to use a lib but getting this error... 尝试使用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.

Not sure what changes are likely needed to make it valid JSON, thanks very much! 不确定可能需要哪些更改才能使其成为有效的JSON,非常感谢!

Just to complete the answer, you can simply use an online JSON validator to validate your package.json . 只是为了完成答案,您只需使用在线JSON验证器来验证您的package.json
I highly recommend http://jsonlint.com/ , paste your package.json in the textarea and click on the Validate button, that's all! 我强烈推荐http://jsonlint.com/ ,将你的package.json粘贴到textarea中,然后单击Validate按钮,这就是全部!

Valid JSON must have both keys and values of an object in quotes. 有效的JSON必须包含引号中对象的键和值。 Surround all of your keys in quotation marks and that should make the error go away. 用引号括住所有键,这应该会使错误消失。

Reference: JSON spec 参考: JSON规范

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

Super cool way to fix / validate the package.json : 修复/验证package.json的超酷方式:

node package.json

and you have your json validated or the error line. 并且您已经验证了json或错误行。

Why use jsonlint , sounds pretty lame. 为什么要使用jsonlint ,听起来很蹩脚。

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

I have been through this problem and in my case it was just that in place of comma(,). 我遇到过这个问题而在我的情况下只是代替逗号(,)。 I have used dot(.). 我用过dot(。)。 You can simply open it up in any JSON validator and it will help you up. 您可以在任何JSON验证器中打开它,它会帮助您。 One of the JSON validator's link is as follows . JSON验证器的一个链接如下。 http://www.bodurov.com/JsonFormatter/ http://www.bodurov.com/JsonFormatter/

我也得到了相同的错误信息,首先运行npm package.json来检查package.json文件中的错误,如果没有则运行npm cache clean

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM