Plugin/Preset files are not allowed to export objects,webpack报错/babel报错的解决方法

1、为什么会报错 ?

  这里抱着错误是因为 babel 的版本冲突。

  多是因为你的 babel 依赖包不兼容。

  可以查看你的 package.json 的依赖列表

  即有 babel 7.0 版本的( @babel/core , @babel/preset-react )

  也可命令查看 bebel-cli 的版本 ( babel -V )

  也有 babel 6.0 版本的 ( [email protected] , [email protected] , [email protected] )

  

  如果在你的 package.json 依赖包中既有 babel 7.0 版本,又有 babel 6.0 版本,就会报这个错误

  很现实就是两个版本是不兼容的

2、处理方法

  1、升级到 babel 7.0

  

  将所有有关 babel 的包都升级为 7.0 版本


1

2

3

4

5

6

"@babel/core""^7.0.0-beta.40",

"@babel/cli""^7.0.0-beta.40",

"babel-loader""^8.0.0-beta.0",

"babel-plugin-lodash""^3.3.2",

"babel-plugin-react-transform""^3.0.0",

"@babel/preset-react""^7.0.0-beta.40",<br>"@babel/preset-stage-0":‘^7.0.0‘

  

  并且修改 .babelrc 文件

  对应的修改  presets 预设和 plugins 都改为 7.0 形式。


1

2

3

4

query: {

   presets: [‘@babel/react‘‘@babel/stage-0‘],

   plugins: [‘‘]

 }

  

  2、降级到 babel 6.0 版本

  

  有时候我们看们的 package.json 里面都是 babel 6.0 版本的。

  如下:

  


1

2

3

4

5

"babel-core""^6.26.0",

"babel-loader""^7.1.2",

"babel-plugin-transform-runtime""^6.23.0",

"babel-preset-env""^1.6.1",

"babel-preset-stage-0""^6.24.1",

  但是还是报错,为什么呢?

  你不妨把 node_modules 删掉,重新 install ,这样就可以处理一部分兼容问题

  如果上面的方法还是不行。

  你可以查看一下 babel-cli 的版本


1

babel -V

  如果是 babel-cli 7.0 版本。

  

  那你就重新安装全局和本地的 babel-cli 版本为 6.0


1

2

3

npm install -g [email protected]

yarn add [email protected]

  

  

  基本上面两个方法可以解决所有兼容问题。

原文地址:https://www.cnblogs.com/tengrl/p/10342839.html

时间: 2024-08-03 19:23:24

Plugin/Preset files are not allowed to export objects,webpack报错/babel报错的解决方法的相关文章

babel版本兼容报错处理:Plugin/Preset files are not allowed to export objects

原文地址: https://www.cnblogs.com/jiebba/p/9618930.html 1.为什么会报错 ? 这里抱着错误是因为 babel 的版本冲突. 多是因为你的 babel 依赖包不兼容. 可以查看你的 package.json 的依赖列表 即有 babel 7.0 版本的( @babel/core , @babel/preset-react ) 也可命令查看 bebel-cli 的版本 ( babel -V ) 也有 babel 6.0 版本的 ( [email pro

react 中使用import()实现按需加载报错 解决方法 --‘import’ and ‘export’ may only appear at the top level

因为项目需要搞一下按需加载,使用import实现代码打包分片按需加载,但是在实际使用中报语法错误.报错信息如下 SyntaxError: 'import' and 'export' may only appear at the top level 啊咧?报错了. 查找发现很多人碰到过,解决方法不同,但是我这个报错适用下边这个方法. npm install --save-dev babel-plugin-syntax-dynamic-import 然后调整babel-loader配置如下: use

【Android-tips】 Unable to execute dex: Multiple dex files define 解决方法

唔,之前已经想过今后不动android,没想到还是因为比赛的原因重操旧业.android有很多问题是由于eclipse的不完善造成的,比如今天遇到的这个问题 Unable to execute dex: Multiple dex files define [2011-10-23 16:23:29 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/myapp/R$array; [2011-10-23 16:23:

Unable to execute dex: Multiple dex files define 解决方法

问题发生概述:       程序编译正常,在用Eclipse调试执行时,报错Unable to execute dex: Multiple dex files define,因为以前也没有遇到这类错误,首先便尝试万能纠错发,如下方法一,也是上网搜索众多解决方案之一,尝试后未果,便按照搜索方案,逐一尝试,都未能解决,最后盯着工程突然发现问题.具体解决方案如下: 方法一:       Eclipse->Project->去掉Build Automatically->Clear ->Bu

在执行ab压力测试时出现socket: Too many open files (24)的解决方法

当入行压力测试时出现下列错误 [[email protected] ~]# ab -n 3000 -c 3000 http://192.168.0.2/This is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, htt

Unable to execute dex: Multiple dex files define 的解决方法

我们在引入library时可能会出现这个错误 比如:[2013-11-05 14:22:15 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/mobile/appstore/listjar/sdk/R$anim;[2013-11-05 14:22:15 - TabHostSample] Conversion to Dalvik format failed: Unable to execute dex: Mul

eclipse:运行 Android 项目时出现 “Unable to execute dex: Multiple dex files define” 解决方法

android 项目在eclipse 出现Unable to execute dex: Multiple dex files define Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define 的原因主要是因为jar包重复导入造成的冲突 这个项目我使用了swipebacklayout的library,library里面已经导入了v7的jar包,项目工程里也有个v7包,解决方法就是将

Host is not allowed to connect to this MySQL server解决方法 可以访问局域网的数据库! 完美解决!

0. http://blog.csdn.net/flyyhz/article/details/77100243 1. 2. 3. 4. 5. 6. 7. 8. 9. 今天在Linux上面装完MySQL,却发现在本地登录可以,但是远程登录却报错Host is not allowed to connect to this mysql server,找了半天试了网上的一些方法都没有解决,最终在一篇文章里找到了解决方法,特意记录一下. 先说说这个错误,其实就是我们的MySQL不允许远程登录,所以远程登录

linux 打开文件数 too many open files 解决方法

linux 打开文件数 too many open files 解决方法 too many open files 出现这句提示的原因是程序打开的文件/socket连接数量超过系统设定值. 查看每一个用户最大同意打开文件数量 ulimit -a [email protected]:~$ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 20 fi