[CLI] SyntaxError: JSON5: invalid character with verbatim command copied from squoosh.app
See original GitHub issueDescribe the bug Copying resize commands from squoosh.app and trying to use them results in SyntaxError and aborted processing.
To Reproduce Steps to reproduce the behavior:
- Go to https://squoosh.app/editor
- Enable resize
- Copy command
- Open a terminal
- Paste the command and append an image file name in that directory
- Press Enter
Expected behavior File is squooshed with those settings Actual:
(node:28880) UnhandledPromiseRejectionWarning: SyntaxError: JSON5: invalid character 'l' at 1:45
at syntaxError (C:\Users\herbst\AppData\Roaming\npm\node_modules\@squoosh\cli\node_modules\json5\lib\parse.js:1083:17)
at invalidChar (C:\Users\herbst\AppData\Roaming\npm\node_modules\@squoosh\cli\node_modules\json5\lib\parse.js:1028:12)
at Object.value (C:\Users\herbst\AppData\Roaming\npm\node_modules\@squoosh\cli\node_modules\json5\lib\parse.js:287:15)
at lex (C:\Users\herbst\AppData\Roaming\npm\node_modules\@squoosh\cli\node_modules\json5\lib\parse.js:78:42)
at Object.parse (C:\Users\herbst\AppData\Roaming\npm\node_modules\@squoosh\cli\node_modules\json5\lib\parse.js:25:17)
at Command.processFiles (file:///C:/Users/herbst/AppData/Roaming/npm/node_modules/@squoosh/cli/src/index.js:137:49)
(node:28880) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:28880) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that
Example command that fails (copied from squoosh.app + " file.jpg"):
npx @squoosh/cli --resize '{"enabled":true,"width":1024,"height":1024,"method":"lanczos3","fitMethod":"stretch","premultiply":true,"linearRGB":true}' --mozjpeg '{"quality":75,"baseline":false,"arithmetic":false,"progressive":true,"optimize_coding":true,"smoothing":0,"color_space":3,"quant_table":3,"trellis_multipass":false,"trellis_opt_zero":false,"trellis_opt_table":false,"trellis_loops":1,"auto_subsample":true,"chroma_subsample":2,"separate_chroma_quality":false,"chroma_quality":75} file.jpg
Version:
- OS w/ version: [e.g. iOS 12]
- Browser w/ version [e.g. Chrome 70]
- Node version: [e.g. 10.11.0]
- npm version: [e.g. 6.4.1]
Is your issue related to the quality of image compression? Please attach original and output images (you can drag & drop to attach).
- Original image
- Output image from Squoosh
Additional context, screenshots, screencasts Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Error while parsing config - JSON5: invalid end of input at 1:1 ...
I have tried using the node_modules/.bin/babel before.js -o after.js command to convert from es6 to compatible js.
Read more >[CLI] SyntaxError: JSON5: invalid character with verbatim command ...
Go to https://squoosh.app/editor; Enable resize; Copy command; Open a terminal; Paste the command and append an image file name in that directory; Press...
Read more >I'm getting this error and can't seem to google my way ... - Reddit
Please run next command `yarn upgrade` SyntaxError: JSON5: invalid end of input at 1:1 at syntaxError (/mnt/d/Coding/projects/nextjs-blog/ ...
Read more >squoosh - bytemeta
[Web] Dragging a new image into squoosh.app resets resize settings ... [CLI] SyntaxError: JSON5: invalid character with verbatim command copied from ...
Read more >Promise { <rejected> { SyntaxError: JSON5: invalid character ...
Unhandled Rejection at: Promise { { SyntaxError: JSON5: invalid character ... The missing documentation tool for your Angular, Nest & Stencil application.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Seems like there is
'
missing. I’ll take a look.on Windows delete keys “method”:“lanczos3”,“fitMethod”:“stretch” at JSONUPD: OS: windows 10 SMD: powershell 7.2.1 NODE: 14.19.3
If you have keys with string parameters, like
"method":"lanczos3"
or"fitMethod":"stretch"
. You need to escape quotes from the key value, like"method":\"lanczos3\"
or"fitMethod":\"stretch\"
. It’s work!UPD2:
It’s work only on squoosh-cli (squoosh install global). Method
npx @squoosh/cli
dosen’t work.Example:
IMPORTANT:
fitMethod: contain
doesn’t work on Windows in cli mode.