Composer json does not contain valid json parse error on line 1

I have the following error with composer 1.7-RC when I do composer update [SeldJsonLintParsingException] "https://repo.packagist.org/packages.json" does not contain valid JSON Parse err...

I went rollback to the version 1.6.5
After I executed :

> composer update --no-plugins

Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating symfony/flex (v1.0.85 => v1.0.86): Downloading (100%)
Writing lock file
Generating autoload files

> composer self-update --snapshot
Updating to version 35389f1cc2ef3abf2a069a21902fb681302e0217 (snapshot channel).
   Downloading (100%)
Use composer self-update --rollback to return to version 1.6.5

> composer update
"https://repo.packagist.org/packages.json" does not contain valid JSON
Parse error on line 1:
▼\\\♥��ݎ♀���
^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
https://repo.packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date

> composer clearcache
Clearing cache (cache-vcs-dir): C:UserscrazyAppDataLocalComposervcs
Clearing cache (cache-repo-dir): C:UserscrazyAppDataLocalComposerrepo
Clearing cache (cache-files-dir): C:UserscrazyAppDataLocalComposerfiles
Clearing cache (cache-dir): C:UserscrazyAppDataLocalComposer
All caches cleared.

> composer update
 [ComposerRepositoryRepositorySecurityException]
The contents of https://repo.packagist.org/p/provider-2013%24e00fadef42535a8348d8f5edccb4a7dd892ac3bf8477c073ec03eb16f1cef7d7.json do not match its signature. This could indicate a man-in-the-middle attack or e.g. antivirus software corrupting files. Try running composer again and report this if you think it is a mistake.

> composer update
"https://repo.packagist.org/packages.json" does not contain valid JSON
Parse error on line 1:
▼\\\♥��ݎ♀���
^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
https://repo.packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
  1. Home

  2. php — composer installed.json» does not contain valid JSON

181 votes

1 answers

Get the solution ↓↓↓

I upgraded laravel 5.4 to laravel 5.5 according to the official documents, and then executed composer update, which returned this error

  - Installing theseer/tokenizer (1.2.0): Extracting archive
  - Installing sebastian/code-unit-reverse-lookup (1.0.2): Extracting archive
  - Installing phpunit/php-code-coverage (5.3.2): Extracting archive
  - Installing phpspec/prophecy (v1.10.3): Extracting archive
  - Installing phar-io/version (1.0.1): Extracting archive
  - Installing phar-io/manifest (1.0.1): Extracting archive
  - Installing myclabs/deep-copy (1.10.2): Extracting archive
  - Installing phpunit/phpunit (6.5.14): Extracting archive
  - Installing predis/predis (v1.1.7): Extracting archive
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package mtdowling/cron-expression is abandoned, you should avoid using it. Use dragonmantank/cron-expression instead.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files


  [SeldJsonLintParsingException]
  "/home/vagrant/work/exports-api/vendor/composer/installed.json" does not co
  ntain valid JSON
  Parse error on line 1:

  ^
  Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

this is my composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0",
        "predis/predis": "^1.1"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~6.0",
        "filp/whoops": "~2.0"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "scripts": {
        "post-root-package-install": [
            "php -r "file_exists('.env') || copy('.env.example', '.env');""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\Foundation\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\Foundation\ComposerScripts::postUpdate",
            "php artisan optimize"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }
}

Then I’ll check the file «/home/vagrant/work/exports-api/vendor/composer/installed.json» It’s a blank, nothing
Supplementary notes
Before the update, there was something in installed.json, and composer update became blank. Now, the composer operation under this project will return this error

2021-09-7

Write your answer


276

votes

Answer

Solution:

I changed the composer version from 2.0 to 1.0 to solve the problem


Share solution ↓

Additional Information:

Date the issue was resolved:

2021-09-7

Link To Source

Link To Answer
People are also looking for solutions of the problem: warning: undefined array key

Didn’t find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.


Similar questions

Find the answer in similar questions on our website.

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.


About the technologies asked in this question

PHP

PHP (from the English Hypertext Preprocessor — hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/

Laravel

Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework.
https://laravel.com/

Foundation

Foundation, similar to Bootstrap, has become very popular as a more complex framework with some advanced but easy-to-implement CSS components. It is built with Sass, so just like Bootstrap, it is customizable. In addition to this, it also boasts some features that help make the design mobile responsive.
https://get.foundation/



Welcome to programmierfrage.com

programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.

Get answers to specific questions

Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.

Help Others Solve Their Issues

Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.

Another article specifying error message which is a Laravel Error Message as stated in the title of this article. The error generated is ‘composer.json does not contain valid json’. In this article, there will be a narration on the cause of the error, the background of how the error is being ignited as the main trigger and the last one is about how to solve the error.

It must be edited because there is some part of the file which is changed after executing the following command :

user@hostname:/var/www/html/laravel-project$ php artisan app:name Laravel-Testing
Application namespace set!
The compiled class file has been removed.
user@hostname:/var/www/html/laravel-project$ vim .env

The cause of error which is actually an indirect cause of directly editing a file named ‘composer.json’ located in the root folder of the laravel project directory. So, the content of composer.js is pointed out in the following location shown in the form of tree format :

user@hostname:/var/www/html/laravel-project$ tree -aL 1
.
├── app
├── artisan
├── bootstrap
├── composer.json
├── composer.lock
├── config
├── database
├── db
├── .env
├── .env.example
├── .gitattributes
├── .gitignore
├── gulpfile.js
├── logs
├── nbproject
├── package.json
├── phpunit.xml
├── public
├── readme.md
├── resources
├── routes
├── server.php
├── storage
├── temporary
├── tests
└── vendor

14 directories, 12 files
user@hostname:/var/www/html/laravel-project$

As shown in the above output generated from the ‘tree’ command execution, the composer.json file is located in the root folder of Laravel project. The error is actually caused from the entry or false editing and input of the file itself. Below is the content of the composer.json file which is being the target of the edit process :

  "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "Laravel-Testing\": "app/"
        }
    },

It is changed and edited into the following content :

  "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
        //    "Laravel-Testing\": "app/"
            "App\": "app/"
        }
    },

Although the edit process is meant to solve the problem by editing or giving a remark sign of comment to the part which caused the problem and it is followed after that by the addition process through inserting a correct line of code, it becomes the background for triggering the error message. As shown in the title, the error is actually has something to do with composer.json which does not contain valid json. It is obvious since the json format content is disrupted with the comment to ruled out the error cause.

To solve it, just remove the snippet code which is becoming the part of the problem and add the actual snippet code chosen for it. So, the composer.json must be edited and it is shown as follows :

  "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },

Try to execute ‘composer dumpautoload -0’ and access the web-based application powered by Laravel framework..

Аватара пользователя

flashimage

Сообщения: 1517
Зарегистрирован: 2011.01.23, 12:43

Composer

windows 7
Собственно код ошибки, не знаю что и делать прям.

[SeldJsonLintParsingException]
«C:ProgramDataComposerbincomposer.bat» does not contain valid JSON
Parse error on line 1:
@ECHO OFF
SET SUBDI
^
Expected one of: ‘STRING’, ‘NUMBER’, ‘NULL’, ‘TRUE’, ‘FALSE’, ‘{‘, ‘[‘

Никто не сталкивался?
Не могу понять чего он лезет в батник чего то искать?

Бранчи это гомеоморфические эндофункторы, которые мапятся на субманифолды пространства Гилберта.

Аватара пользователя

flashimage

Сообщения: 1517
Зарегистрирован: 2011.01.23, 12:43

Re: Composer

Сообщение

flashimage » 2014.02.03, 12:55

composer update
Файл composer.json в папке есть
Собственно на работе Убунту — на ней все бегает. Видать я опять где-то накранил.))

Бранчи это гомеоморфические эндофункторы, которые мапятся на субманифолды пространства Гилберта.

Аватара пользователя

samdark

Администратор
Сообщения: 9467
Зарегистрирован: 2009.04.02, 13:46
Откуда: Воронеж
Контактная информация:

Re: Composer

Сообщение

samdark » 2014.02.03, 14:27

Попробуйте убить Composer и все его следы и поставить заново из официального инсталлера.

Аватара пользователя

hippik

Сообщения: 57
Зарегистрирован: 2011.12.11, 23:33
Откуда: Москва

Re: Composer

Сообщение

hippik » 2014.02.06, 18:00

Подскажите, а то уже стыдно не уметь composerom пользоваться :oops:
Мне нужно установить расширение https://github.com/yiisoft/yii2/tree/ma … ns/imagine

В корневой папке сайта composer установлен (composer.phar,composer.json присутствуют)
Запускаю из этой папки

Код: Выделить всё

php composer.phar require --prefer-dist yiisoft/yii2-imagine "*" 

Появляется ошибка

Код: Выделить всё

composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package yiisoft/yii2-imagine could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

Я вообще правильно делаю? Из той папки запускаю?

читал
http://www.yiiframework.com/forum/index … icomposer/
Но так и не разобрался(
пс. linux

Аватара пользователя

futbolim

Сообщения: 2051
Зарегистрирован: 2012.07.08, 19:28

Re: Composer

Сообщение

futbolim » 2014.02.06, 18:20

просто добавьте в composer.json (в корневой папке проекта) в секцию require:
«yiisoft/yii2-imagine»: «*»
и потом в корневой папке откройте терминал и composer update
всё

Аватара пользователя

hippik

Сообщения: 57
Зарегистрирован: 2011.12.11, 23:33
Откуда: Москва

Re: Composer

Сообщение

hippik » 2014.02.06, 19:28

Да благодарю. Так заработало!
Еще подскажите пожалуйста.Новый проект.
1)Создаем папочку.
2) Устанавливаем туда composer

Код: Выделить всё

curl -sS https://getcomposer.org/installer | php  

3) берем от сюда ссылку на установку
https://github.com/yiisoft/yii2-app-basic

Код: Выделить всё

php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic

и появляется ошибка

Код: Выделить всё

Installing yiisoft/yii2-app-basic (dev-master 5dbf082210b28030e83791bdfe6a1a4a64d99747)
  - Installing yiisoft/yii2-app-basic (dev-master master)
    Loading from cache

Created project in /var/www/test/yii2-app-basic
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Почему так?
И сразу второй вопрос.
Если я просто в этой папке создам такой файл composer.json https://github.com/yiisoft/yii2/blob/ma … poser.json
и наберу

то появится опять та же ошибка.
Что я делаю не так?

Аватара пользователя

futbolim

Сообщения: 2051
Зарегистрирован: 2012.07.08, 19:28

Re: Composer

Сообщение

futbolim » 2014.02.06, 20:11

зайдите в свою папку с сайтом, полностью очистите и запустите:
php composer.phar create-project —prefer-dist —stability=dev yiisoft/yii2-app-basic ./

Аватара пользователя

Vodazar

Сообщения: 77
Зарегистрирован: 2014.02.25, 13:05

Re: Composer

Сообщение

Vodazar » 2014.09.08, 12:49

Помогите разобраться с composer.
На windows 7 перехожу в каталог локального хоста.
Жмякаю в меню «Use Composer here»
ввожу:
composer create-project —prefer-dist —stability=dev yiisoft/yii2-app-basic ./

на что получаю такое сообщение

Изображение

ничего не ставится соответственно. Что делать?

Аватара пользователя

yiijeka

Сообщения: 3103
Зарегистрирован: 2012.01.28, 09:14
Откуда: Беларусь
Контактная информация:

Re: Composer

Сообщение

yiijeka » 2014.09.08, 13:47

Всё вы делаете правильно — должно работать. У вас наверное что-то с интернет подключением не то. Мб брандмауэр или прокси сервер или ещё что-то.


Я создал сценарий composer.json.

Когда я запускаю sudo composer install, я получаю эту ошибку:

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

Вот 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"
}

Как я могу получить лучшее описание того, как этот JSON неверен?

4 answers

Ваш JSON плохой, вставьте свой JSON на этот веб-сайт: http://jsonlint.com/

Он возвращает ошибку:

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

Если вы окружите весь свой JSON символом { в начале и } в самом конце, недопустимый 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"
  }
}

Кавычки в моем текстовом редакторе были недопустимы, попробуйте скопировать и вставить это в свой текстовый файл: «

 -1

Author: Charlie, 2016-10-17 09:07:10

H i, I get the following error on generation page:

Code: Select all

    Checking PHP CLI...
Running composer update -n --no-suggest...
**In JsonFile.php line 347:
  "./composer.json" does not contain valid JSON
  Parse error on line 12:
  ...store.com"		}	],	"requ
  -------------------^
  Invalid string, it appears you forgot to terminate a string, or attempted to write a multiline string which is inva
  lid - It appears you have an extra trailing comma**
update [--with WITH] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--no-autoloader] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>...]
node:internal/errors:857
  const err = new Error(message);
              ^
Error: Command failed: composer update -n --no-suggest
    at checkExecSyncError (node:child_process:861:11)
    at execSync (node:child_process:932:15)
    at global.Exec (C:Program Files (x86)PHPMaker 2020nodenode_modulesphpmakerphpmaker.js:7:361766)
    at global.RunComposerUpdate (C:Program Files (x86)PHPMaker 2020nodenode_modulesphpmakerphpmaker.js:7:361593)
    at C:Program Files (x86)PHPMaker 2020nodenode_modulesphpmakerphpmaker.js:7:365994 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 2824,
  stdout: null,
  stderr: null
}

composer:

Composer version 2.5.1 2022-12-22 15:33:54
root@webdev:/var/www/html/flow# composer selfupdate
You are already using the latest available Composer version 2.5.1 (stable channel).

composer json:

Code: Select all

{
	"name": "hkvstore/phpmaker",
	"version": "2020",
	"type": "project",
	"homepage": "https://phpmaker.dev/",
	"license": "Commercial",
	"authors": [
		{
			"name": "e.World Technology Limited",
			"email": "sales@hkvstore.com"
		}
	],
	"require": {
		"php": ">=5.6.0",
		"phpmailer/phpmailer": "~6.0.7",
		"ezyang/htmlpurifier": "^4.11.0",
		"mobiledetect/mobiledetectlib": "^2.8.33",
		"soundasleep/html2text": "^0.5.0",
		"slim/slim": "^3.12.1",
		"tuupola/slim-jwt-auth": "^2.4",
		"slim/http-cache": "^0.4.0",
		"defuse/php-encryption": "~2.2.1",
		"hkvstore/phpthumb": "~2.1.1",
		"athari/yalinqo": "^2.4.2",
		"dflydev/dot-access-data": "^1.1.0",
		"delight-im/cookie": "^3.3.1",
		"hkvstore/dompdf": "0.8.303 - 0.8.399",
		"kint-php/kint": "^5.0.2",
		"ncjoes/office-converter": "^1.0.3",
		"spatie/pdf-to-image": "^2.2.0",
		"sunnysideup/presentation": "^1.0.1",
		"twilroad/presentation": "^0.10.0"
	},
	"autoload": {}
}

php maker + extensions

Version 2020.0.16

template

2020.0.16 download 01.2023

any sugestions?

Понравилась статья? Поделить с друзьями:
  • Component mscomct2 ocx or one of its dependencies not correctly registered как исправить
  • Component error code 1639
  • Complete error vba
  • Complete error variable not defined
  • Complete error user defined type not defined