【问题标题】:Receive parse error for package.json. Validates as valid json收到 package.json 的解析错误。验证为有效的 json
【发布时间】:2015-04-14 21:15:55
【问题描述】:

我正在尝试创建我的第一个 yeoman 生成器,当我运行 yo 来创建我的项目时出现以下错误。

npm ERR! install Couldn't read dependencies
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.10.35
npm ERR! npm  v2.1.14
npm ERR! file /Users/derek/Development/personal_projects/stylus-generator/work/package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Unexpected token }
npm ERR! File: /Users/derek/Development/personal_projects/stylus-generator/work/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

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/derek/Development/personal_projects/stylus-generator/work/npm-debug.log

我已经使用 jsonlint 验证了 package.json 文件。我还执行了 npm cache clean。 package.json 文件可以在这里找到:https://github.com/dereksnow/generator-simple-stylus/blob/master/package.json

有什么建议吗?

【问题讨论】:

  • 看起来他希望您的 JSON 作为字符串,而不是 javascript 对象文字。
  • @Tyr,它验证为 JSON。我认为如果在字符串的上下文中使用 npm 会处理。如果它验证为 JSON,我不确定还有什么可以看的。有什么建议吗?
  • @Barun 在发布我的问题之前,我已经查看了这个答案。我相信我的问题是不同的,因为我注意到 package.json 文件本身是有效的 JSON。因此,此问题/答案提请注意其他用户也可能由于错误消息而错过的依赖关系中的潜在问题。

标签: javascript json node.js npm package.json


【解决方案1】:

在我的 app/templates/_package.json 文件中的最后一个依赖项之后,我有一个逗号。我正在查看根目录中的 package.json,它没有任何问题。哎呀!

【讨论】:

    猜你喜欢
    • 2018-10-28
    • 1970-01-01
    • 1970-01-01
    • 2022-07-14
    • 2021-11-12
    • 1970-01-01
    • 2018-07-14
    • 2017-05-01
    • 1970-01-01
    相关资源
    最近更新 更多