-
-
Couldn't load subscription status.
- Fork 335
Description
- 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
fast-xml-parser/.github/workflows/node.js.yml
Lines 17 to 18 in 1a384a5
| 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