adamreisnz / replace-in-file

A simple utility to quickly replace contents in one or more files
580 stars 65 forks source link

SyntaxError: Unexpected token '/', "//config f"... is not valid JSON #196

Closed gokhangunduz closed 3 months ago

gokhangunduz commented 3 months ago

Hi, sorry for second issue but i have a new problem. I have React project and already used 7.2.0 version of replace-in-file in some components. I wanna upgrade replace-in-file from 7.2.0 to 8.0.1 but the following error when of upgraded compiling process.

Compiling...
SyntaxError: Unexpected token '/', "//config f"... is not valid JSON
    at JSON.parse (<anonymous>)
    at loadConfig (file:///C:/Users/user/react-project/node_modules/replace-in-file/src/helpers/config.js:17:23)
    at async main (file:///C:/Users/user/react-project/node_modules/replace-in-file/bin/cli.js:24:31)
ERROR: "cleanWarning" exited with 1.
adamreisnz commented 3 months ago

As per the change log, the config file for replace-in-file should now be JSON format. Comments are not valid JSON as per the error, hence this no longer parses correctly.

If you require non-JSON config files, I recommend you stay with version 7 for the time being.