Angular 6+: SyntaxError: Unexpected token import
See original GitHub issueIts not working for me. I am using Angular 6+ but I always get this error:
src\setup-jest.ts:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import 'jest-preset-angular';
^^^^^^
SyntaxError: Unexpected token import
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
What can be the issue? How can we resolve it?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
How to Resolve Typescript Error Unexpected Token Import?
Uncaught SyntaxError: Unexpected token import at src/test.js:1. My tsconfig.json in the \src folder is as follows:
Read more >missing file lib/angular2-modal/plugins/bootstrap.js
I am working on angular2-modal popup, after compiling when I try to launch the application I am getting this error in browser console,...
Read more >Unexpected token import; After updating from Angular 2 RC5 ...
Coding example for the question Uncaught SyntaxError: Unexpected token import; After updating from Angular 2 RC5 to Angular 2 Final;-angular.js.
Read more >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 >node unexpected token export - You.com | The AI Search ...
Node.js - SyntaxError: Unexpected token import ... While you are tranpiling your own source files, angular is deployed as ES2015 ... Answered on...
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
hi all, please add
"module": "commonjs",
to yourtsconfig.spec.json
. It will solve your issue 😃@l7960261 you can try to run clear cache of jest, it should solve after modifying
tsconfig.spec.json
. It worked for me. Here is the repo