babel 在编译箭头函数时报 "Unexpected token" 问题
来源:互联网 发布:编制图片软件 编辑:程序博客网 时间:2024/05/15 15:45
babel 在编译箭头函数时报错问题
今天在用webpack打包时遇到了如下错误:
Module build failed: SyntaxError: D:/workspace/vs/simple-database/app/containers/App.jsx: Unexpected token (86:7) 84 | } 85 |> 86 | test = () => { | ^ 87 | return ''; 88 | } 89 |
我的.babelrc为
{ "presets": [ "es2015", "react" ], "env": { "start": { "presets": [ "react-hmre" ] } }}
查找原因为箭头函数为ES7所支持的语法所以要修改.babelrc文件为
{ "presets": [ "es2015", "react", "stage-1" ], "env": { "start": { "presets": [ "react-hmre" ] } }}
还记得要安装这个预设
npm install -D babel-preset-stage-1
问题解决。
0 0
- babel 在编译箭头函数时报 "Unexpected token" 问题
- 使用Babel独立版编译ES6代码时报错误:Unexpected token <
- TransformError Unexpected token node_modules\babel-preset-react-native.........
- Debug: babel arrow function 'unexpected token' in React.Component
- exp 导多个用户数据时报 syntax error near unexpected token `('
- webpack打包vue文件时报错`Unexpected token:`
- vuejs遇到unexpected token {的问题
- Unexpected token }
- Unexpected token <
- 解决 webstrom 上的 babel 编译问题
- 关于jS编译时报Uncaught SyntaxError: Unexpected identifier
- CentOS6.5导入Oracle数据库时报错syntax error near unexpected token
- js 使用eval函数 报错uncaught syntaxerror: unexpected token :
- 解决cygwin中的 syntax error near unexpected token问题
- syntax error near unexpected token `then'问题的解决
- syntax error near unexpected token `问题的解决
- syntax error near unexpected token `then'问题的解决
- jquery ajaxfileupload 上传控件 Uncaught SyntaxError: Unexpected token < 问题
- Zoneminder
- Spark流处理解读(3)JOB源码解读
- Android IOC 框架ViewInject(上)
- Fresco简单的使用—SimpleDraweeView
- 关于c#数据库的简单应用-datagriview连接数据库及更相关操作
- babel 在编译箭头函数时报 "Unexpected token" 问题
- iOS开发系列--打造自己的“美图秀秀”
- 毛玻璃效果
- 类的成员函数做回调函数
- 【HUSTOJ】1073: 拐角VI
- hdoj2044注意要用long long否则会溢出
- spring ApplicationContext
- 第十一周实践项目2-存储班长信息的学生类
- PAT-B 1033. 旧键盘打字