【React】配置react-hot-loader后出现import' and 'export' may only appear at the top level
来源:互联网 发布:香橙派 ubuntu 编辑:程序博客网 时间:2024/05/19 11:48
在搭建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 6to5), make sure React Hot Loader stays to the left of Babel inloaders
array 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']
},
阅读全文
1 0
- 【React】配置react-hot-loader后出现import' and 'export' may only appear at the top level
- import declarations may only appear at top level of a module
- babel & browserify 报错 'import' and 'export' may appear only with 'sourceType: module' (2:0)
- 使用 react-hot-loader
- 使用 react-hot-loader
- react-hot-loader记录
- 【XML码农】【Error】The XML declaration may only appear at the very beginning of the document.
- webpack配置react-hot-loader热加载局部更新
- ReactNative警告:bind(): React component methods may only be bound to the component instance
- Warning: bind(): React component methods may only be bound to the component instance. See ...
- React官方API:Top-Level API
- React Native的import和export的使用
- react-native Hot Reloading
- React-"Refs and the DOM"
- react-native 在android运行时报UNEXPECTED TOP-LEVEL EXCEPTION
- Oracle import and export
- Hbase export and import
- Unsafe code may only appear if compiling with /unsafe
- android绘图之Path总结
- MAT(Memory Analyzer Tool)工具入门介绍
- Knights of Ni(两次bfs)
- 组合数求模模板
- CountVectorizer、TfidfTransformer、TfidfVectorizer关系
- 【React】配置react-hot-loader后出现import' and 'export' may only appear at the top level
- Effective C++笔记
- 521356
- Qt5--文本编辑器 (二)
- node核心模块之path
- iOS导航栏创建
- Django Model
- 各种正则:邮箱,电话号码,身份证号。
- mac版本idea使用(四)