composer update error - composer.json does not contain valid JSON (v2020)

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
gregor4711
User
Posts: 66

composer update error - composer.json does not contain valid JSON (v2020)

Post by gregor4711 »

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

    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 2020\node\node_modules\phpmaker\phpmaker.js:7:361766)
    at global.RunComposerUpdate (C:\Program Files (x86)\PHPMaker 2020\node\node_modules\phpmaker\phpmaker.js:7:361593)
    at C:\Program Files (x86)\PHPMaker 2020\node\node_modules\phpmaker\phpmaker.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:

{
	"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?


arbei
User
Posts: 9347

Post by arbei »

As you see, the JSON in composer.json is valid.


gregor4711
User
Posts: 66

Post by gregor4711 »

Hi,

the message says " "./composer.json" does not contain valid JSON Parse error on line 12:"

I'm wondering as I understund the concept php maker is managing valid json file which composer can handle during compelation / generation process.

I do not change any template file nor composer.json Why phpmaker is stating this error and where it came from?

BR
J


arbei
User
Posts: 9347

Post by arbei »

The error is reported by Composer, not by PHPMaker. Composer found error in your composer.json. You may test by opening the generated composer.json with Firefox and see if it can be read by the browser correctly. I have old project in v2020 and the composer.json is good.

It seems that there is some invalid whitespaces in your composer.json:

  Parse error on line 12:
  ...store.com"		}	],	"requ
  -------------------^

You may open the file in a text editor, check the white spaces or remove the white spaces at where the error said.

If you have modified the composer.json manually, make sure you save the file in utf-8 which is the expected encoding of a .json file.

If your template is a third party or a modified template, you better use the default/original one shipped with v2020.

Also, you better:

  1. Uninstall Composer and install again,
  2. Delete your composer.josn and vendor folder,
  3. Generate all files again and run "composer update" again.

Post Reply