Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fxparser CLI doesn't start when running with node 22 #718

Closed
5 of 7 tasks
tbouffard opened this issue Feb 20, 2025 · 3 comments
Closed
5 of 7 tasks

fxparser CLI doesn't start when running with node 22 #718

tbouffard opened this issue Feb 20, 2025 · 3 comments

Comments

@tbouffard
Copy link
Contributor

tbouffard commented Feb 20, 2025

  • Are you running the latest version? 5.0.2
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?
  • Have you checked the docs for helpful APIs and examples?

Description

When running the CLI with node 22, an JSON import fails. Running with Node 16, 18 or 20 works
Tests have been done with Ubuntu 22.04.

node v22.14.0 (npm v10.9.2)

$ fxparser --help
file:////code/test_f-x-p/node_modules/fast-xml-parser/src/cli/cli.js:8
import pkg from '../../package.json' assert { type: 'json' };
                                     ^^^^^^

SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:338:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:102:18)
    at #translate (node:internal/modules/esm/loader:468:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:515:27)
    at async ModuleJob._link (node:internal/modules/esm/module_job:115:19)

node v18.20.6 (npm v10.8.2)

$ fxparser --help
Fast XML Parser 5.0.2
----------------
$ fxparser [-ns|-a|-c|-v|-V] <filename> [-o outputfile.json]
$ cat xmlfile.xml | fxparser [-ns|-a|-c|-v|-V] [-o outputfile.json]

Options
----------------
-ns: remove namespace from tag and atrribute name.
-a: don't parse attributes.
-c: parse values to premitive type.
-v: validate before parsing.
-V: validate only.

node v20.18.3 (npm v10.8.2) generates the following warnings

(node:68298) V8: file:///code/test_f-x-p/node_modules/fast-xml-parser/src/cli/cli.js:8 'assert' is deprecated in import statements and support will be removed in a future version; use 'with' instead
(Use `node --trace-warnings ...` to show where the warning was created)
(node:68298) V8: file:///code/test_f-x-p/node_modules/fast-xml-parser/src/cli/man.js:1 'assert' is deprecated in import statements and support will be removed in a future version; use 'with' instead

Possible fix

As mentioned in the node 20 warnings, replacing 'assert' by 'with' in the JSON imports work (I have tested it locally), for node 18, 20 and 22.
But this is not working with node 16.

Applying the changes depends on the Node version fast-xml-parser wants to support. Currently, this is unclear to me.
There is no information in the README and documentation, and there is no "engines" field in the package.json that could help.

The GitHub workflow is running with various Node versions, but they are all end of life

matrix:
node-version: [10.x, 12.x, 14.x, 16.x]

Notes

Would you like to work on this issue?

  • Yes. The node versions that are supported should be clarified first
  • No
@amitguptagwl
Copy link
Member

They are all end of life but still being used by many projects. I wanted to add new versions to the list. I would have to look for some workaround in this case.

@amitguptagwl
Copy link
Member

I hope it should be working fine with 5.0.4 now.

@tbouffard
Copy link
Contributor Author

This now works, thanks.
So, I close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants