vue router loading on demand times error
{
path: '/product',
component: () => import('./pages/product'),
},
error: Module build failed: SyntaxError: Unexpected token
solution:
1. In the beginning, I was in a hurry to write something, but instead of studying it carefully, I changed it to another way:
{
path: '/product',
component:resolve => require(['./pages/product'], resolve),
},
found no error and ran successfully. Later baidu checked that the original Babel needs to be added with
syntax-dynamic-import
plug-in, so that the Babel can correctly parse the syntax.
2. Download the plug-in
npm install babel-plugin-syntax-dynamic-import --save-dev
3. Then modify the loader configuration
in webpack
{
test: /\.js$/,
loader:'babel-loader',
options:{
plugins:['syntax-dynamic-import']
},
},
so far, problem solved
my personal blog, drop by sometime
Read More:
- [system]SyntaxError: Unexpected token u in JSON at position 0
- Module parse failed:Unexpected token (9:6)
- chunk-vendors.7142f8da.js:1 Uncaught SyntaxError: Unexpected token ‘<‘
- 2021-07-03module parse failed: unexpected token (763:13) you may need an appropriate loader to
- Webpack error module build failed: typeerror: fileSystem.statSync is not a function
- Webpack — module build failed: error: the node API for ‘Babel’ has been moved to Babel core
- Module build failed (from ./node_modules/babel-loader/lib/index.js) babel-loader
- Unexpected syntax error: unexpected token<
- How to Fix webpack Module build failed Error: The node API for ‘babel’ has been moved to babel-core
- ERROR in static/js/app.xxxxxxx.js from UglifyJs Unexpected token: operator (>)
- Module build failed: error:couldn’t find preset “env” relative to directory
- Module build failed: error: cannot find module ‘node sass’ error
- syntax error near unexpected token `then’ problem solution
- Module build failed: TypeError [ERR_INVALID_ARG_TYPE]: The “path“ argument must be of type string.
- Syntax error: unexpected token in uni app project compilation
- Vue の NPM run serve error: parsing error: unexpected token<
- Module build failed Error Plugin/Preset files are not allowed to export objects, only functions (How to Fix)
- Solve the problem of syntax error: unexpected end of file or syntax error near unexpected token ` fi ‘error
- Vue — report error with less module build failed: typeerror: loaderContext.getResolve is not a function
- Parsing error: Unexpected token