`Uncaught SyntaxError: Unexpected token !` with `new Method` usage
See original GitHub issueBug report
What is the current behavior? Fails with an expection
If the current behavior is a bug, please provide the steps to reproduce.
import Method from 'path/to/unexisting/module';
new Method();
It will be transpiled to
new !(function webpackMissingModule() { var e = new Error("Cannot find module 'path/to/unexisting/module'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())(params);
What is the expected behavior? Proper exception with proper error message and stack.
Other relevant information: webpack version: 4.19.1 Node.js version: v10.13.0 Operating System: MacOS
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >SyntaxError: Unexpected token in JavaScript | bobbyhadz
The "Uncaught SyntaxError: Unexpected token" occurs for multiple reasons: · The error is also caused if you're making an HTTP request to a...
Read more >Uncaught SyntaxError: Unexpected token : - Stack Overflow
"Uncaught SyntaxError: Unexpected token" error appearance when your data return wrong json format, in some case, you don't know you got wrong json...
Read more >Uncaught SyntaxError: Unexpected token < - JavaScript - iDiallo
All it means is that the interpreter is expecting JavaScript or JSON and you are feeding it HTML/XML. If you don't think you...
Read more >[Support Guide] Why do I see “Uncaught SyntaxError ...
The error Uncaught SyntaxError: Unexpected token < is most commonly caused by your site's code referring to an asset that is no longer...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ajaygangarde as a workaround - just click on the link to the code place where the exception happened and you’ll see the exact missing path in the generated code.
Fixed https://github.com/webpack/webpack/pull/10424 (webpack@5)