Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

finchy70's avatar

Composer Problems

I have installed Composer on windows and when I run composer -v I get the following error.

[Seld\JsonLint\ParsingException]
 "C:\Users\Paal\.config\herd\bin\composer.bat" does not contain valid JSON
 Parse error on line 1:
 @...
 ^
 Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

I have tried downloading the standalone composer.phar from the composer website and replacing the one in the bin folder but I get he same issue.

Anyone got any ideas why this is happening?

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

It looks like Composer is trying to parse a file as JSON, but it's actually a batch file (composer.bat). This usually happens if your COMPOSER_HOME or COMPOSER environment variable is set incorrectly, or if you are running Composer from a location where it expects a composer.json or composer.lock file, but finds something else.

Here's how you can troubleshoot and fix this:

1. Check Your Environment Variables

Make sure you don't have a COMPOSER environment variable pointing to the wrong file. To check:

  1. Open Command Prompt.
  2. Run:
set COMPOSER

If you see something like:

COMPOSER=C:\Users\Paul.config\herd\bin\composer.bat

That's the problem. The COMPOSER variable should point to a composer.json file if set, or not be set at all for global usage.

To remove it:

  • Open System Properties > Environment Variables.
  • Find and delete the COMPOSER variable.

2. Check Your Current Directory

Make sure you're not running composer in a directory where a file named composer.bat exists. Composer might be trying to parse that file.

3. Reinstall Composer

If the above doesn't help, try uninstalling and reinstalling Composer:

  • Uninstall Composer from "Add or Remove Programs".
  • Delete any remaining composer.phar or composer.bat files in your PATH.
  • Download and install Composer again from getcomposer.org.

4. Verify Composer Installation

After reinstalling, open a new Command Prompt and run:

composer --version

You should see the Composer version output, not a JSON error.


Summary:
The error is because Composer is trying to parse a .bat file as JSON. Remove or correct any COMPOSER environment variable, ensure you're not in a directory with a composer.bat file, and reinstall Composer if needed. This should resolve your issue.

1 like

Please or to participate in this conversation.