-
Notifications
You must be signed in to change notification settings - Fork 104
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
How to fix Module parse failed: Unexpected token #140
Comments
That's a webpack config issue. Specifically, it's due to using ES6 syntax in your webpack config. See: https://stackoverflow.com/questions/63759629/simple-webpack-build-fails-because-of-new-es-syntax Simple solution is to upgrade to Webpack 5, which readily supports ES2020 syntax. |
Next.js has adopted webpack 5 as the default for compilation. |
Ah, I see. Well, the issue is related to webpack not being able to recognize ES2020, so I assume there is a config setup needed to ensure that it can. I would search related to webpack 5 failing to parse nullish coalescing for javascript. Hope that helps! |
I faced the same error when I use this library with "nuxt": "^2.15.7". It looks indeed correct that (maybe latest) webpack can not recognize ESNext(=Es2020). This will be solved by the previous version of this library(ex v3.3.6) as workaround. Because this version seems to publish JS as older ECMA version. Therefore webpack can recognize it. |
@taoqf If it's going to cause issues for a few people, an easy fix is to change the |
@nonara es2019 could not be used |
Ah ok. I believe it's target that needs to be changed (-t flag). Might want to check to see if the nullish coalescing ( If it's still there you can probably just set the t flag to es2019 and it should be good. |
Hi everyone, I used node-html-parse for project reactjs with nextjs.
But when I import node-html-parse, it shows this error.
./node_modules/node-html-parser/dist/esm/nodes/node.js
Module parse failed: Unexpected token (13:26)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| writable: true,
| configurable: true,
| });
| }
Please help me resolve this error.
Thank all.
The text was updated successfully, but these errors were encountered: