“EMALFORMED Failed to read bower.json” on “bower install requirejs-text”

£可爱£侵袭症+ 提交于 2019-12-03 04:41:36

There are two syntax errors in your JSON file. The first error was a missing , after "bootstrap": "~3.1.1". This is why you got the error message you had. The "jquery" string on the next line was not expected. I found this error by inspecting your file by eye. Loading it in a JavaScript or a JSON editor would also have revealed it.

The second error was the comma after {}. A JavaScript parser won't have a problem with it but the JSON parser does. I presume a JSON editor would have revealed this problem. I discovered it by relying on the new error message I got and trial and error.

Here's the fixed file:

{
  "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": {}
}
Mangled Deutz

[UPDATE]

Louis' answer is likely the correct one here! I'm letting mine in for reference, but it's probably not correct for the OP specific case.

[INITIAL ANSWER]

You are on windows, and you are using a text editor that adds a BOM to your bower.json file when editing it.

Then bower complains about it because it can't read it (EMALFORMED) - which is quite accurate, if not really helpful about what the issue is.

The solution: start your bower.json file from scratch, using a text editor that doesn't sucks (and doesn't add a BOM).

See here, and here, for other people in the same case.

(and this is unrelated to requirejs-text - it's your bower.json file which is malformed)

I had a similar error for a .bower.json file in my solution, and for some reason the content of that file had been deleted during an automated process. I was able to delete the file and pull it back from source control, which fixed my issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!