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

Failed to Compile, with this error. #1237

Closed
ns-bc opened this issue Jul 6, 2022 · 8 comments
Closed

Failed to Compile, with this error. #1237

ns-bc opened this issue Jul 6, 2022 · 8 comments

Comments

@ns-bc
Copy link

ns-bc commented Jul 6, 2022

What could be the cause of this? In a CRA.

./node_modules/htmlparser2/lib/esm/index.js 67:9
Module parse failed: Unexpected token (67:9)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|   return getFeed(parseDOM(feed, options));
| }
> export * as DomUtils from "domutils"; // Old name for DomHandler      
|
| export { DomHandler as DefaultHandler };
@yanm1ng
Copy link

yanm1ng commented Jul 6, 2022

same problem

@manbhush
Copy link

manbhush commented Jul 6, 2022

+1

2 similar comments
@yarrrrrrik
Copy link

+1

@yannickrocks
Copy link

+1

@Diljeetsinghsuri
Copy link

Was facing the same issue. It seems to be the issue with the latest version. A quick workaround is to fix the version of htmlparser2 in your package json and re-run npm install cmd. So It won't update the package version to latest.

@lukescott
Copy link

export * as ns is a later extension of the module syntax and is supported in webpack 5.

See webpack/webpack#10460

I ran into this because:

  • Our projects are still using webpack 4
  • We are using html-to-react, which updated from htmlparser2 7 to 8 between 1.4 and 1.5 and we are using ^.

A few solutions:

  • Upgrade to webpack 5
  • If you are using babel already, you can use @babel/plugin-proposal-export-namespace-from as mentioned in the webpack issue
  • You can target files/packages that use htmlparser2 and use resolve.mainFields in a rule to tell it to use main instead of module. For us doing this globally broke other things.
  • Lock the dependency to a version that still uses htmlparser2 v7.

@fb55
Copy link
Owner

fb55 commented Jul 13, 2022

Thanks for the great write up @lukescott! I understand that this is annoying for everyone affected.

This change was part of a major version, which does allow for breaking changes. I don't see an easy way to work around this issue without negative side effects for users with modern tooling, so unfortunately this won't be fixed. Hope that makes sense!

@ljharb
Copy link

ljharb commented Jan 22, 2023

Isn’t the easy fix to do it in two lines?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants