Paste error information to facilitate search engines to find similar errors
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
D:\123\vue3-pro\h5-editor\node_modules\[email protected]@lodash-es\lodash.js:10
export { default as add } from './add.js';
^^^^^^
SyntaxError: Unexpected token 'export'
Solution
After checking online for a long time, I finally found the only way to solve my problem. If the common methods on the Internet are useless, friends can try
According to the reply to the question, you can configure the following in jest. Config. JS
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!lodash-es)"
]
Read More:
- Vue Import three.JS error: Unexpected token [How to Solve]
- [Solved] vue Project Error: react lazy eslint error Parsing error: Unexpected token import
- How to Solve JS error: Unexpected end of JSON input,Unexpected token u in JSON at position 0
- [Solved] React Startup Error at the First time :SyntaxError: Unexpected token
- [Solved] Uncaught SyntaxError: Unexpected token ‘<‘
- ArcGIS API for JavaScript version 4. X updated and the project startup error: Module parse failed: Unexpected token(… …
- [Solved] ESLint: Parsing error: Unexpected token(prettier/prettier)
- vue3 import Error: has no default export [How to Solve]
- [Solved] Webpack compile error: SyntaxError: Unexpected token =
- [Solved] Error in created hook: “SyntaxError: Unexpected token o in JSON at position 1“
- Error in created hook: “SyntaxError: Unexpected token u in JSON at position 0
- [Solved] Vue project configurate test environment and package error
- [Solved] Vue Error: Syntax Error: TypeError: Cannot set properties of undefined (setting ‘XXX’)
- How to Solve Vue3 using deep syntax Error
- How to Solve Vue cli syntax Close Error
- [Solved] Vue Project Start Error: Support for the experimental syntax ‘jsx‘ isn‘t currently enabled
- [Solved] Vue Error: Error: Rule can only have one resource source (provided resource and test + include + ex
- [Solved] Uncaught SyntaxError: The requested module does not provide an export named
- [Solved] Vue2.0 Error: Syntax Error: TypeError: eslint.CLIEngine is not a constructor