-1

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:

[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?

yivi
  • 42,438
  • 18
  • 116
  • 138
Martin
  • 311
  • 1
  • 2
  • 20

1 Answers1

2

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.)

Moshe Katz
  • 15,992
  • 7
  • 69
  • 116