简体   繁体   English

Babel没有从JSX转换为JS,在没有使用webpack / browserify / bower的情况下手动尝试

[英]Babel not transpiling from JSX to JS, tried manually without using webpack/browserify/bower

I am trying basic example in React.JS and using Babel to transpile from jsx to js. 我正在尝试React.JS中的基本示例,并使用Babel从jsx转换为js。 I hope I installed all babel dependencies, shown in package.json below. 我希望我安装了所有babel依赖项,如下面的package.json所示。 Also added App.jsx and index.html pages. 还添加了App.jsx和index.html页面。

As shown in line 8 of package.json, I am trying to execute babel with "npm run build" but it is throwing error as shown in this terminal screenshot. 如package.json的第8行所示,我正在尝试使用“npm run build”执行babel,但它正在抛出错误,如此终端屏幕截图所示。

Any help appreciated. 任何帮助赞赏。

在此输入图像描述

在此输入图像描述

在此输入图像描述 在此输入图像描述

This happens when you don't configure Babel (properly). 当您不配置Babel(正确)时会发生这种情况。

Add this to your package.json : 将它添加到你的package.json

"babel" : {
  "presets": ["es2015", "react" ]
}

More information here . 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM