jsx-parser
jsx-parser copied to clipboard
NodeJS fails to import the package, because this package uses CommonJS instead of ES Modules
When I installed the package from npm into my NodeJS cli project I got the following error:
export default JSXParser
^^^^^^
SyntaxError: Unexpected token 'export'
When I looked in the code I discovered that the type property was not set inside the package.json By default NodeJS uses CommonJS instead of the ES Modules syntax with import and export.
This can be fixed by setting the type property in the package.json file to "module".
even though this sollution will not work for older NodeJS versions (older than version 15.3.0) it does work for the modern versions
sorry he has passed away
Who?