Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Issues while installing Composer and requiring frameworks

I am setting up a small dev environment.

  • Ubuntu 20.04
  • PHP 7.4.3
  • Composer 2.2.6

I have Composer installed.

 Composer version 2.2.6 2022-02-04 17:00:38

I am attempting to require php-jwt. I run composer require firebase/php-jwt. When I do this, I get the following error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

[Seld\JsonLint\ParsingException]
    "./composer.json" does not contain valid JSON
    Parse error on line 1:
    
    ^
    Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

When I cat composer.json in my working directory, there is nothing in it. Are there default options that should be in composer.json?

*UPDATE

Thank you to @Moshe Katz

The fix:

  • Delete existing composer.json
  • Run composer init

>Solution :

You cannot have composer.json as an empty file, because an empty file is not a valid JSON object. (At a minimum, a valid JSON object looks like {}.)

Delete that file and run composer init to set up your project properly, or manually create it as a valid file following the documentation. (I recommend the init command over manual creation, because it will ask you a series of questions to help build the file.)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading