Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

composer.json error: "./composer.json" does not contain valid JSON [closed]

I made a composer.json script.

When I run sudo composer install, I get this error:

[Seld\JsonLint\ParsingException]               
"./composer.json" does not contain valid JSON  
Parse error on line 1:                         
"repositories": [    {        "t               
--------------^                                
Expected one of: 'EOF', '}', ',', ']'          

Here is the JSON:

"repositories": [
    {
        "type":"package",
        "package": {
          "name": "AdamKyle/Aisis-Core",
          "version":"development",
          "source": {
              "url": "https://github.com/AdamKyle/Aisis-Core.git",
              "type": "git",
              "reference":"development"
            }
        }
    }
],
"require": {
    "AdamKyle/Aisis-Core": "development"
}

How can I get a better description of how this JSON is wrong?

like image 582
Adam Avatar asked Sep 20 '13 02:09

Adam


2 Answers

Your JSON is bad, Paste your JSON into this website: http://jsonlint.com/

It returns the error:

Parse error on line 1:
"repositories": [  
^
Expecting '{', '['

If you surround your entire JSON with a { at the beginning and } at very end, the invalid JSON becomes valid.

like image 196
Eric Leschinski Avatar answered Sep 22 '22 12:09

Eric Leschinski


I'll share my $0.02. More than once I have faced this problem because of GIT conflicts. So sometimes your composer.lock will have the following conflict indications:

<<<<<<< HEAD
"funding": [
{
    "url": "https://github.com/jenssegers",
    "type": "github"
},
{
    "url": "https://tidelift.com/funding/github/packagist/jenssegers/agent",
    "type": "tidelift"
}
],
=======
>>>>>>> a19a747062fe0ace379f410ad94e27463eee436c

This stuff got injected when a git conflict was not resolved properly, thereby making the lock file invalid. To fix this problem, simply remove the conflicting sections of your lock file by comparing it with the file history.

like image 37
dotNET Avatar answered Sep 20 '22 12:09

dotNET