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 版本的 ( babel-core@6.26.0 , babel-cli@6.26.0 , babel-preset-react@6.24.1 )
如果在你的 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 babel-cli@6.26.0 yarn add babel-cli@6.26.0 |
基本上面两个方法可以解决所有兼容问题。
babel版本兼容报错处理:Plugin/Preset files are not allowed to export objects的更多相关文章
- Plugin/Preset files are not allowed to export objects,webpack报错/babel报错的解决方法
1.为什么会报错 ? 这里抱着错误是因为 babel 的版本冲突. 多是因为你的 babel 依赖包不兼容. 可以查看你的 package.json 的依赖列表 即有 babel 7.0 版本的( @ ...
- webpack 使用 extract-text-webpack-plugin 报错 Tapable.plugin is deprecated. Use new API on .hooks instead
webpack 使用 extract-text-webpack-plugin 报错 Tapable.plugin is deprecated. Use new API on .hooks instea ...
- python3.7环境下创建app、运行Django1.11版本项目报错Generator expression must be parenthesized
有些同学喜欢追求新鲜感~但追求新鲜感终归是要付出一点点代价的 在编程领域有一句至理名言:用东西不要用最新的! 就像每次苹果系统的升级都会有相当一部分用户的手机成砖一样 下面我们就介绍一个因版本升级带来 ...
- SpringBoot与jackson.databind兼容报错问题
SpringBoot与jackson.databind兼容报错问题 ———————————————— 1.SpringBoot版本V2.0.0其依赖的jackson-databind版本为V2.9.4 ...
- mysql5.6版本备份报错
MySQL5.6版本备份报错,密码不安全 [root@centos199 mysql]# mysqldump -uroot -ppassword cz-office > mysql38.sqlW ...
- 从高版本JDK换成低版本JDK报错Unsupported major.minor version 52.0的解决方案
从高版本JDK换成低版本JDK报错Unsupported major.minor version 52.0 java.lang.UnsupportedClassVersionError: PR/Sor ...
- python3.7环境下创建app,运行Django1.11版本项目报错SyntaxError: Generator expression must be parenthesized
咳咳!!! 今天用命令行创建django项目中的app应用,出现了这样一个错误 这个错误在python3.6版本下安装运行django 1.11版本正常运行,但python3.7版本下运行django ...
- phpstudy切换的php7.1版本php-cgi报错
phpstudy切换的php7.1版本php-cgi报错 是因为没有装对应vc的插件. 下载地址:https://www.microsoft.com/zh-CN/download/details.as ...
- Nginx报错: "Too many open files accept" 和 "could not build the server_names_hash"
一.访问Nginx时,报错:"accept() failed (24: Too many open files)"原因时:nginx的连接数超过了系统设定的最大值造成的. 处理办法 ...
随机推荐
- 源码安装python +NGINX 的坎坷路 +uwsgi安装 部署django 的CRM项目
一.Nginx安装(基于ubuntu17.10 版本) 首先我们是基于源码安装,主要有如下步骤 1.安装依赖包 1.安装gcc g++的依赖库 sudo apt-get install build-e ...
- Scala语言笔记 - 第一篇
目录 Scala语言笔记 - 第一篇 1 基本类型和循环的使用 2 String相关 3 模式匹配相关 4 class相关 5 函数调用相关 Scala语言笔记 - 第一篇 最近研究了下scala ...
- java points[复习]
1 - & 与 && 的区别: &:不管左边是true还是false,右端都会进行运算: &&:当左端为false时,右端不再进行运算: 即在与运算时, ...
- mysql uodate 报错 You can't specify target table '**' for update in FROM clause
You can't specify target table 'sc' for update in FROM clause 背景:把“sc”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩: 上面 ...
- centos7 64运行32位程序
yum在线安装: sudo yum install xulrunner.i686 或者: sudo yum install ia32-libs.i686 PS:可以查看一下当前源库里有没有ia32-l ...
- Oracle 的开窗函数 rank,dense_rank,row_number
1.开窗函数和分组函数的区别 分组函数是指按照某列或者某些列分组后进行某种计算,比如计数,求和等聚合函数进行计算. 开窗函数是指基于某列或某些列让数据有序,数据行数和原始数据数相同,依然能曾现个体数据 ...
- 初学Java的那段日子
最近因为一个朋友想要学习Java,在帮助他找教程的过程中回想到了我自己当年学习Java的那段岁月,故写了此篇文章总结了一下初学Java所必须要掌握的知识点,然后把一部分常见的面试题罗列出来.给予刚刚开 ...
- [Swift]LeetCode305. 岛屿的个数 II $ Number of Islands II
A 2d grid map of m rows and n columns is initially filled with water. We may perform an addLand oper ...
- [Swift]LeetCode564. 寻找最近的回文数 | Find the Closest Palindrome
Given an integer n, find the closest integer (not including itself), which is a palindrome. The 'clo ...
- [Swift]LeetCode1026. 节点与其祖先之间的最大差值 | Maximum Difference Between Node and Ancestor
Given the root of a binary tree, find the maximum value V for which there exists different nodes A a ...