html-react-parser icon indicating copy to clipboard operation
html-react-parser copied to clipboard

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)

Open giovannirosa opened this issue 2 years ago • 12 comments

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

giovannirosa avatar Nov 01 '23 18:11 giovannirosa

Thanks for opening this issue @giovannirosa! Can you provide a reproducible example?

remarkablemark avatar Nov 01 '23 18:11 remarkablemark

Same issue. React 18 OS Win 11

1978milanbabic avatar Nov 03 '23 14:11 1978milanbabic

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;
};

1978milanbabic avatar Nov 03 '23 16:11 1978milanbabic

Thanks @1978milanbabic. Do you have a reproducible example so I can verify the bug?

remarkablemark avatar Nov 03 '23 16:11 remarkablemark

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..

1978milanbabic avatar Nov 03 '23 16:11 1978milanbabic

Hi I'm having the same issue. How would I give you a reproducible example? I'm on React 16.8.6.

olupelumi avatar Nov 23 '23 00:11 olupelumi

@olupelumi can you create a CodeSandbox? See JavaScript or TypeScript

remarkablemark avatar Nov 23 '23 01:11 remarkablemark

Got the same Error with the version 5.0.7

React 17.0.1 OS Win 11 Project: SharePoint Framework 1.18.2

6gal6ler6 avatar Dec 09 '23 15:12 6gal6ler6

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 avatar Mar 05 '24 17:03 jaiprep

@jaiprep Can you provide a reproducible example with StackBlitz?

remarkablemark avatar Mar 05 '24 17:03 remarkablemark

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 avatar Dec 16 '24 10:12 Diogofmr

@Diogofmr see if this Stackoverflow solves the issue for you

remarkablemark avatar Dec 16 '24 15:12 remarkablemark