BOM错误,input未检测到错误

这是我的JSON

{ "name": "dockerizing-magento", "description": "ADockerizedMagentoCommunityEdition", "require": { "magento-hackathon/magento-composer-installer": "v2.1.1", "magento/core": "1.9.1.0-patch1" }, "require-dev": {}, "repositories": [], "extra": { "magento-root-dir": "web", "auto-append-gitignore": true }, "config": { "discard-changes": true }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { "post-install-cmd": [], "post-update-cmd": [] } } 

当我尝试composer update

它给出的错误

[SELD \ JsonLint \ ParsingException]
“./composer.json”不包含有效的JSON
检测到BOM,确保您的input不包含Unicode Byte-Order-Mark

更新[–prefer-source] [–prefer-dist] [–dry-run] [–dev] [–no-dev] [–lock] [–no-plugins] [–no -custom-installers] [–no-autoloader] [–no-scripts] [–no-progress] [–with-dependencies] [-v | vv | vvv | –verbose] [-o | – -optimize-autoloader] [-a | –classmap-authoritative] [–ignore-platform-reqs] [–prefer-stable] [–prefer-lowest] [-i | –interactive] [–root – 要求] [ – ] [] …

但根据几个网站是有效的

https://jsonformatter.curiousconcept.com/

例如这里

我遵循这个教程

https://andykdocs.de/development/Docker/Dockerize-Magento

但几个小时,我得到了这个错误。 请帮忙

我试图在docker里面build一个magento。

字节顺序标记 (简称BOM)是只存在于文件中的东西。 当编辑器或文本查看器呈现您的composer.json ,它会删除BOM,所以如果您将composer.json的内容粘贴到基于Web的linter中,它将不再具有BOM,所以基于Web的工具粘贴到,将validation它。 你应该做的是从文件中删除BOM,你可以使用从这个答案借来的awk命令

 mv composer.json composer-bom.json # rename file with BOM awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}{print}' composer-bom.json > composer.json rm -f composer-bom.json # delete file with BOM 
Interesting Posts