skip to Main Content

We just got a fresh new Magento 2.4.6 p3 CE version installed.

So we do want to install some extensions starting with these module:

composer require mageplaza/module-core

`In JsonFile.php line 347:

"./composer.json" does not contain valid JSON
Parse error on line 79:
…s": [{ ,"http-basic": {

Expected one of: ‘STRING’, ‘}’
`

We get this error at CLI

Apparently, my composer.json file got an error. Below details on our file.

Please explain for me how to fix it. Thanks!

{
    "name": "magento/project-community-edition",
    "description": "eCommerce Platform for Growth (Community Edition)",
    "type": "project",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "config": {
        "allow-plugins": {
            "dealerdirect/phpcodesniffer-composer-installer": true,
            "laminas/laminas-dependency-plugin": true,
            "magento/*": true,
            "php-http/discovery": true
        },
        "preferred-install": "dist",
        "sort-packages": true
    },
    "version": "2.4.6-p3",
    "require": {
        "magento/product-community-edition": "2.4.6-p3",
        "magento/composer-dependency-version-audit-plugin": "~0.1",
        "magento/composer-root-update-plugin": "~2.0"
    },
    "autoload": {
        "exclude-from-classmap": [
            "**/dev/**",
            "**/update/**",
            "**/Test/**"
        ],
        "files": [
            "app/etc/NonComposerComponentRegistration.php"
        ],
        "psr-0": {
            "": [
                "app/code/",
                "generated/code/"
            ]
        },
        "psr-4": {
            "Magento\": "app/code/Magento/",
            "Magento\Framework\": "lib/internal/Magento/Framework/",
            "Magento\Setup\": "setup/src/Magento/Setup/"
        }
    },
    "require-dev": {
        "allure-framework/allure-phpunit": "^2",
        "dealerdirect/phpcodesniffer-composer-installer": "^0.7",
        "dg/bypass-finals": "^1.4",
        "friendsofphp/php-cs-fixer": "^3.8",
        "lusitanian/oauth": "^0.8",
        "magento/magento-coding-standard": "*",
        "magento/magento2-functional-testing-framework": "^4.3.1",
        "pdepend/pdepend": "^2.10",
        "phpmd/phpmd": "^2.12",
        "phpstan/phpstan": "^1.9",
        "phpunit/phpunit": "^9.5",
        "sebastian/comparator": "<=4.0.6",
        "sebastian/phpcpd": "^6.0",
        "symfony/finder": "^5.4",
        "symfony/process": "<=v5.4.23"
    },
    "conflict": {
        "gene/bluefoot": "*"
    },
    "autoload-dev": {
        "psr-4": {
            "Magento\PhpStan\": "dev/tests/static/framework/Magento/PhpStan/",
            "Magento\Sniffs\": "dev/tests/static/framework/Magento/Sniffs/",
            "Magento\TestFramework\Inspection\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
            "Magento\TestFramework\Utility\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
            "Magento\Tools\": "dev/tools/Magento/Tools/",
            "Magento\Tools\Sanity\": "dev/build/publication/sanity/Magento/Tools/Sanity/"
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true,
{   
    "repositories": [
{        
    ,"http-basic": {
        "repo.magento.com": {
            "username": "<your public key>",
            "password": "<your private key>"
        }
    }
}   
{       
        ,"mageplaza": {
            "repo.mageplaza.com": {
            "username": "<your mageplaza public key>",
            "password": "<your mageplaza private key>"
        }
    }
}
}
    ],
    "extra": {
        "magento-force": "override"
    }
}

2

Answers


  1. Here is your composer.json, you added multiples parenthesis and commas wich were not correct :

    {
        "name": "magento/project-community-edition",
        "description": "eCommerce Platform for Growth (Community Edition)",
        "type": "project",
        "license": [
            "OSL-3.0",
            "AFL-3.0"
        ],
        "config": {
            "allow-plugins": {
                "dealerdirect/phpcodesniffer-composer-installer": true,
                "laminas/laminas-dependency-plugin": true,
                "magento/*": true,
                "php-http/discovery": true
            },
            "preferred-install": "dist",
            "sort-packages": true
        },
        "version": "2.4.6-p3",
        "require": {
            "magento/product-community-edition": "2.4.6-p3",
            "magento/composer-dependency-version-audit-plugin": "~0.1",
            "magento/composer-root-update-plugin": "~2.0"
        },
        "autoload": {
            "exclude-from-classmap": [
                "**/dev/**",
                "**/update/**",
                "**/Test/**"
            ],
            "files": [
                "app/etc/NonComposerComponentRegistration.php"
            ],
            "psr-0": {
                "": [
                    "app/code/",
                    "generated/code/"
                ]
            },
            "psr-4": {
                "Magento\": "app/code/Magento/",
                "Magento\Framework\": "lib/internal/Magento/Framework/",
                "Magento\Setup\": "setup/src/Magento/Setup/"
            }
        },
        "require-dev": {
            "allure-framework/allure-phpunit": "^2",
            "dealerdirect/phpcodesniffer-composer-installer": "^0.7",
            "dg/bypass-finals": "^1.4",
            "friendsofphp/php-cs-fixer": "^3.8",
            "lusitanian/oauth": "^0.8",
            "magento/magento-coding-standard": "*",
            "magento/magento2-functional-testing-framework": "^4.3.1",
            "pdepend/pdepend": "^2.10",
            "phpmd/phpmd": "^2.12",
            "phpstan/phpstan": "^1.9",
            "phpunit/phpunit": "^9.5",
            "sebastian/comparator": "<=4.0.6",
            "sebastian/phpcpd": "^6.0",
            "symfony/finder": "^5.4",
            "symfony/process": "<=v5.4.23"
        },
        "conflict": {
            "gene/bluefoot": "*"
        },
        "autoload-dev": {
            "psr-4": {
                "Magento\PhpStan\": "dev/tests/static/framework/Magento/PhpStan/",
                "Magento\Sniffs\": "dev/tests/static/framework/Magento/Sniffs/",
                "Magento\TestFramework\Inspection\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
                "Magento\TestFramework\Utility\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
                "Magento\Tools\": "dev/tools/Magento/Tools/",
                "Magento\Tools\Sanity\": "dev/build/publication/sanity/Magento/Tools/Sanity/"
            }
        },
        "minimum-stability": "stable",
        "prefer-stable": true,
        "repositories": {        
          "http-basic": {
              "repo.magento.com": {
                  "username": "<your public key>",
                  "password": "<your private key>"
              }
          },
          "mageplaza": {
              "repo.mageplaza.com": {
              "username": "<your mageplaza public key>",
              "password": "<your mageplaza private key>"
            }
          },
          "extra": {
              "magento-force": "override"
          }
        }
    }
    
    Login or Signup to reply.
  2. It looks like there are some syntax errors in your composer.json file. Specifically, there are extra commas and missing braces in the "repositories" section. Here’s a corrected version of your composer.json file:

    {
        "name": "magento/project-community-edition",
        "description": "eCommerce Platform for Growth (Community Edition)",
        "type": "project",
        "license": [
            "OSL-3.0",
            "AFL-3.0"
        ],
        "config": {
            "allow-plugins": {
                "dealerdirect/phpcodesniffer-composer-installer": true,
                "laminas/laminas-dependency-plugin": true,
                "magento/*": true,
                "php-http/discovery": true
            },
            "preferred-install": "dist",
            "sort-packages": true
        },
        "version": "2.4.6-p3",
        "require": {
            "magento/product-community-edition": "2.4.6-p3",
            "magento/composer-dependency-version-audit-plugin": "~0.1",
            "magento/composer-root-update-plugin": "~2.0",
            "mageplaza/module-core": "*" // Add this line to require Mageplaza module-core
        },
        "autoload": {
            "exclude-from-classmap": [
                "**/dev/**",
                "**/update/**",
                "**/Test/**"
            ],
            "files": [
                "app/etc/NonComposerComponentRegistration.php"
            ],
            "psr-0": {
                "": [
                    "app/code/",
                    "generated/code/"
                ]
            },
            "psr-4": {
                "Magento\": "app/code/Magento/",
                "Magento\Framework\": "lib/internal/Magento/Framework/",
                "Magento\Setup\": "setup/src/Magento/Setup/"
            }
        },
        "require-dev": {
            // ... (no changes here)
        },
        "conflict": {
            "gene/bluefoot": "*"
        },
        "autoload-dev": {
            // ... (no changes here)
        },
        "minimum-stability": "stable",
        "prefer-stable": true,
        "repositories": [
            {
                "type": "composer",
                "url": "https://repo.magento.com/"
            },
            {
                "type": "composer",
                "url": "https://repo.mageplaza.com/"
            }
        ],
        "extra": {
            "magento-force": "override"
        }
    }
    

    Make sure to add "mageplaza/module-core": "*" to the "require" section if you want to install the Mageplaza module-core. After making these changes, try running the composer require command again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search