加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

【React】配置react-hot-loader后出现import' and 'exp

发布时间:2020-12-15 06:53:49 所属栏目:百科 来源:网络整理
导读:在搭建React开发环境是使用react-hot-loader时出现了import' and 'export' may only appear at the top level错误,当时考虑到使用的版本存在问题,通过官方git发现如下办法解决; 解决办法: If you're using React Hot Loader together with Babel (ex 6to

在搭建React开发环境是使用react-hot-loader时出现了import' and 'export' may only appear at the top level错误,当时考虑到使用的版本存在问题,通过官方git发现如下办法解决;

解决办法:

If you're using React Hot Loader together withBabel(ex 6to5),make sure React Hot Loader staysto the leftof Babel inloadersarray in Webpack config

大致意思是在使用Babel时如果版本大于5之后需要将react-hot-loader放在babel-loader的前面,调整顺序之后,执行编译名称果然错误不存在了。

但是产生了./node_modules/react-pure-render/function.js错误,通过错误信息可以知道jsx时去编译了node_modules文件夹下的js文件,可以在添加include或exclude属性来指定或排除不需要编译的文件夹

rules: [{ test: /.jsx?$/,include: path.join(__dirname,'src'),loader: ['react-hot-loader','babel-loader'] },

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读