Error screenshot:
Error message:
Module parse failed: Unexpected token (16:9)
File was processed with these loaders:
./node_modules/cache-loader/dist/cjs.js *
./node_modules/babel-loader/lib/index.js *
./node_modules/eslint-loader/index.js
You may need an additional loader to handle the result of these loaders.
| } from ‘@/api/util’;
| export * from ‘./modules/demo’;
export * as openPlatform from ‘./modules/openPlatform’;
| export * as appStore from ‘./modules/appStore’;
| export * as networkElement from ‘./modules/networkElement’;
Problem statement:
For the vue2 project, after npm install, npm run dev runs the project, and the error is reported as above.
I have been looking at this problem for a day. . . . . . . . . . . .
At the beginning, I kept searching for error messages, and all the results from Baidu were to configure webpack, add vue-loader, etc., but it has not been able to solve the problem.
Insert a sentence here ( emphasis!!! ):
If your error message is similar to this:
File was processed with these loaders:
XXXX......
You may need an additional loader to handle the result of these loaders.
Then your error message must point to vue
a file or css
code under these two sentences , then you can rest assured that like most search answers, configurewebpack
If it points to the js code like my screenshot , then there is something wrong with your js code! ! ! , I didn't notice at first whoop whoop
problem solved:
The code in my js file above is like this
export * as openPlatform from ‘./modules/openPlatform’;
export * as appStore from ‘./modules/appStore’;
export * as networkElement from ‘./modules/networkElement’;
Before Webpack 5
, this kind Webpack
of export * as name1 from …
export syntax was not supported, and my webpack
version was 4+, so it caused an error
Change it to the following:
import * as test from './test.js';
export {
test }
over~