SyntaxError: Unexpected token import
See original GitHub issueJest Test Suite fails to run. Does the module need any Babel presets “es2015, react, stage-0,1?” / plugins, when building with webpack. (currently only react-native & react-native-web are present)
Dev builds go through absolutely fine, but the test’s fail at -> unexpected token import from lodash-es\debounce
node_modules\recyclerlistview\node_modules\lodash-es\debounce.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import isObject from './isObject.js';
^^^^^^
SyntaxError: Unexpected token import
at new Script (vm.js:51:7)
at Object.<anonymous> (node_modules/recyclerlistview/dist/web/core/RecyclerListView.js:41:18)
important bits of package.json:
"webpack-dev-server": "2.8.2",
"webpack": "3.5.1",
"react": "16.3.2",
"react-native": "0.55.3",
"react-native-web": "0.6.1",
"recyclerlistview": "1.3.4"
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
],
If the issue is missing something important, hit me up.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
Node.js - SyntaxError: Unexpected token import - Stack Overflow
Use transpiler like Babel to use import in Nodejs as it is not natively supported in nodejs.There is best alternative of import is...
Read more >SyntaxError: Unexpected token import in Node.js | bobbyhadz
The "SyntaxError: Unexpected token import" occurs when we use the ES6 import syntax in a version of Node that doesn't support it. To...
Read more >Unexpected token import Node.js - Reactgo
In this tutorial, we are going to learn about how to resolve the unexpected token import error in Node.js.
Read more >Nodejs Uncaught SyntaxError: Unexpected token import
An unexpected token import occurs when an error message appears in the console while running a web application.
Read more >Error Unexpected token import in nodejs | Edureka Community
SyntaxError : Unexpected token import at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:387:25) at Object.Module.
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 FreeTop 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
Top GitHub Comments
Our solution to this issue:
We added
recyclerlistview
to thetransformIgnorePatterns
property ofjest.config.js
. This appears to be properly transpiling things now.jest.config.js
:I’m getting a very similar error when testing the recyclerlistview. Is there something I’m missing?
Error
Test suite failed to run
package.json
“dependencies”:{
}, “devDependencies”: {
}, “jest”: {
}