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

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) #1143

Open
giovannirosa opened this issue Nov 1, 2023 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@giovannirosa
Copy link

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 giovannirosa added the bug Something isn't working label Nov 1, 2023
@remarkablemark
Copy link
Owner

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

@1978milanbabic
Copy link

Same issue.
React 18
OS Win 11

@1978milanbabic
Copy link

1978milanbabic commented Nov 3, 2023

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

@remarkablemark
Copy link
Owner

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

@1978milanbabic
Copy link

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

@olupelumi
Copy link

olupelumi commented Nov 23, 2023

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

@remarkablemark
Copy link
Owner

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

@6gal6ler6
Copy link

Got the same Error with the version 5.0.7

React 17.0.1
OS Win 11
Project: SharePoint Framework 1.18.2

@jaiprep
Copy link

jaiprep commented Mar 5, 2024

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

@remarkablemark
Copy link
Owner

remarkablemark commented Mar 5, 2024

@jaiprep Can you provide a reproducible example with StackBlitz?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants