gpt4 book ai didi

javascript - "EMALFORMED Failed to read bower.json"上 "bower install requirejs-text"

转载 作者:行者123 更新时间:2023-12-03 02:41:26 26 4
gpt4 key购买 nike

当我尝试安装requirejs-text时,我收到一个我不明白的错误。

$ bower install requirejs-text
bower EMALFORMED Failed to read /Users/bgolder/projects/explorer/front/bower.json

Additional error details:
Unexpected string

在 Bower.json 中,我看不出有什么问题。

{
"name": "front",
"version": "0.0.0",
"dependencies": {
"bootstrap": "~3.1.1"
"jquery": "~1.10.2",
"requirejs": "~2.1.9",
"requirejs-text": "~2.0.10",
"underscore": "~1.5.2",
"backbone": "~1.1.0",
"modernizr": "~2.6.2"
},
"devDependencies": {},
}

如果我在 Bower 上使用详细选项,我会得到此跟踪。

bower                       EMALFORMED Failed to read /Users/bgolder/projects/explorer/front/bower.json

Additional error details:
Unexpected string

Stack trace:
SyntaxError: Unexpected string
at Object.parse (native)
at /usr/local/lib/node_modules/bower/node_modules/bower-json/lib/json.js:41:29
at fs.js:266:14
at /usr/local/lib/node_modules/bower/node_modules/graceful-fs/graceful-fs.js:104:5
at Object.oncomplete (fs.js:107:15)
From previous event:
at readJson (/usr/local/lib/node_modules/bower/lib/util/readJson.js:17:6)
at Project._readJson (/usr/local/lib/node_modules/bower/lib/core/Project.js:539:25)
at Project._analyse (/usr/local/lib/node_modules/bower/lib/core/Project.js:445:14)
at Project.install (/usr/local/lib/node_modules/bower/lib/core/Project.js:47:17)

Console trace:
Trace
at StandardRenderer.error (/usr/local/lib/node_modules/bower/lib/renderers/StandardRenderer.js:74:17)
at Logger.<anonymous> (/usr/local/lib/node_modules/bower/bin/bower:114:22)
at Logger.EventEmitter.emit (events.js:95:17)
at Logger.emit (/usr/local/lib/node_modules/bower/node_modules/bower-logger/lib/Logger.js:29:39)
at /usr/local/lib/node_modules/bower/lib/commands/install.js:35:16
at _rejected (/usr/local/lib/node_modules/bower/node_modules/q/q.js:797:24)
at /usr/local/lib/node_modules/bower/node_modules/q/q.js:823:30
at Promise.when (/usr/local/lib/node_modules/bower/node_modules/q/q.js:1035:31)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/bower/node_modules/q/q.js:741:41)
at /usr/local/lib/node_modules/bower/node_modules/q/q.js:557:44

System info:
Bower version: 1.3.1
Node version: 0.10.26
OS: Darwin 13.1.0 x64

这仍然不能解释问题所在。

最佳答案

您的 JSON 文件中有两个语法错误。第一个错误是 "bootstrap": "~3.1.1" 之后缺少 ,。这就是您收到错误消息的原因。下一行的 "jquery" 字符串不是预期的。我通过肉眼检查你的文件发现了这个错误。在 JavaScript 或 JSON 编辑器中加载它也会显示它。

第二个错误是 {} 后面的逗号。 JavaScript 解析器不会有问题,但 JSON 解析器会出现问题。我认为 JSON 编辑器会揭示这个问题。我根据收到的新错误消息以及反复试验发现了它。

这是固定文件:

{
"name": "front",
"version": "0.0.0",
"dependencies": {
"bootstrap": "~3.1.1",
"jquery": "~1.10.2",
"requirejs": "~2.1.9",
"requirejs-text": "~2.0.10",
"underscore": "~1.5.2",
"backbone": "~1.1.0",
"modernizr": "~2.6.2"
},
"devDependencies": {}
}

关于javascript - "EMALFORMED Failed to read bower.json"上 "bower install requirejs-text",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22890694/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com