Upgrading to latest version 5.0.3 throws compiling error: Can't reexport the named export 'Comment' from non EcmaScript module (only default export is available)
Expected Behavior
The package at version 5.0.3 should compile without errors.
Actual Behavior
Failed to compile.
./node_modules/html-react-parser/esm/index.mjs
Can't reexport the named export 'Comment' from non EcmaScript module (only default export is available)
Steps to Reproduce
Using React 17.0.2, run npm i html-react-parser@latest, run npm start.
Upgrading to the latest v4 version displays no issues.
Environment
- Version: 5.0.3
- Platform: React 17.0.2
- Browser: irrelevant
- OS: Windows 11
Thanks for opening this issue @giovannirosa! Can you provide a reproducible example?
Same issue. React 18 OS Win 11
This is a webpack issue for 'older' packages
Here is the solution that worked for me:
1.
npm i --save react-app-rewired
2.
In package.json "scripts" wherever you have 'react-scripts' -> replace with 'react-app-rewired'
like this:
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject",
create 'config-overrides.js' file in root folder 4. save config file with this content:
module.exports = function override(webpackConfig) {
webpackConfig.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
});
return webpackConfig;
};
Thanks @1978milanbabic. Do you have a reproducible example so I can verify the bug?
Thanks @1978milanbabic. Do you have a reproducible example so I can verify the bug?
Sorry, I work on a huge project and this was a MUST, ;) Luckily, found this solution..
Hi I'm having the same issue. How would I give you a reproducible example? I'm on React 16.8.6.
@olupelumi can you create a CodeSandbox? See JavaScript or TypeScript
Got the same Error with the version 5.0.7
React 17.0.1 OS Win 11 Project: SharePoint Framework 1.18.2
need help with this same with react 18.2.0 html-react-parser/esm/index.mjs Can't reexport the named export 'Comment' from non EcmaScript modul
@jaiprep Can you provide a reproducible example with StackBlitz?
Anyone found a solution? Im using some older versions, react 16.14. And I tried to use it when implementing the statefull chat from azure (Dependency: @azure/communication-react). It requires the html-react-+arser but i had the same error
@Diogofmr see if this Stackoverflow solves the issue for you