报错解决:You may need an additional loader to handle the result of these loaders.

报错信息如下

  • vue 项目
Module parse failed: Unexpected token (1:9)
File was processed with these loaders:
 * ./node_modules/@vue/cli-plugin-babel/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.
> export * as homeApi from './modules/homeDataPanel';
| export * as loginApi from './modules/login';
| export * as collegApi from './modules/basicWork/collegeManger';

在这里插入图片描述
根因是:当前webpack/babel 识别不了 export * as x x x from xxxx的语法(export 和 import的组合使用)

解决

npm i @babel/preset-env @babel/plugin-transform-modules-commonjs -D

  • 在babel.config.js中配置
module.exports = {
   
  presets: [
    '@babel/preset-env',
    ...
  ],
  plugins: [
    '@babel/plugin-transform-modules-commonjs',
    ....
  ]
};

或者 在.babelrc中配置

{  
  "presets": ["@babel/preset-env"],  
  "plugins": ["@babel/plugin-transform-modules-commonjs"]  
}

相关推荐

  1. easyexcel解决

    2023-12-06 14:40:05       59 阅读
  2. Mybatis解决

    2023-12-06 14:40:05       33 阅读
  3. okhttpclient.setsslsocketfactory 解决

    2023-12-06 14:40:05       60 阅读
  4. yum命令解决

    2023-12-06 14:40:05       67 阅读
  5. 解决Rust Cargo

    2023-12-06 14:40:05       29 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-06 14:40:05       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-06 14:40:05       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-06 14:40:05       82 阅读
  4. Python语言-面向对象

    2023-12-06 14:40:05       91 阅读

热门阅读

  1. 如何关闭vue项目中的[eslint]校验

    2023-12-06 14:40:05       66 阅读
  2. CSS外边距重叠:原理、结果

    2023-12-06 14:40:05       43 阅读
  3. LeetCode1005. Maximize Sum Of Array After K Negations

    2023-12-06 14:40:05       38 阅读
  4. vue打包完成后出现空白页原因及解决

    2023-12-06 14:40:05       64 阅读
  5. 代数学笔记8: Sylow定理

    2023-12-06 14:40:05       46 阅读
  6. Vue2学习笔记(数据监测)

    2023-12-06 14:40:05       57 阅读
  7. 【C/C++】可变参数va_list与格式化输出

    2023-12-06 14:40:05       56 阅读
  8. Windows如何启动MySQL

    2023-12-06 14:40:05       52 阅读
  9. Pytorch:torch.utils.data.random_split()

    2023-12-06 14:40:05       56 阅读
  10. VB.NET二维数组的组合

    2023-12-06 14:40:05       72 阅读
  11. 通俗讲解分布式锁:场景和使用方法

    2023-12-06 14:40:05       46 阅读