This time I will show you how to use babel in Webstorm to convert ES6 to ES5, and how to use babel in Webstorm to convert ES6 to ES5. What are the precautions?The following is a practical case, let’s take a look take a look.
Foreword: ECMAScript 6 is the next generation standard of the JavaScript language, which was officially released in June 2015. Mozilla will launch JavaScript based on this standard 2.0. The goal of ES6 is to enable the JavaScript language to be used to write large and complex applications and become an enterprise-level development language. However, modern browsers do not have high support for the new features of ES6, so if you want to use the new features of ES6 directly in the browser, you must use other tools.
Today I will share how to configure Webstorm to use babel to automatically transcode ES6 to ES5. Babel is a widely used transcoder. Babel can perfectly convert ES6 code to ES5 code, so we can use ES6 features in our projects without waiting for browser support.
1. Create a new empty project in Webstorm and name it es6demo.
2. Then create a new package.json under the root directory, and only need to specify two attributes, namely name and version.
3. Open the webstorm terminal (Terminal), the shortcut key is Alt F12, Installbabel-cli. It can also be installed globally.
Install babel-cli: npm install --save-dev babel-cli
4. After installing babel-cli, you can see that a node_modules file and a package-lock.json file are newly generated. At the same time, it is found that there is an extra
"devDependencies": { "babel-cli": "^6.26.0" }# in the package.json file. ## Such a line of code indicates that babel-cli has been successfully installed and has become a dependency. 5. Then select the Javascript option in Settings->Languages & Frameworks, and select the version version as ECMAScript6. 6. In the webstorm terminal (Terminal), install Babel’s preset to correctly identify ES6 code. The command is as follows:
npm install --save-dev babel-preset-es2015After installation, there will be an additional in the package.json file. "babel-preset-es2015": "^6.24.1" This line of code indicates that babel-preset-es2015 has also been successfully installed. 7. Create a new file named .babelrc under the root directory with the following content:
{ "presets": [ "es2015" ] }8. Set up File Watcher. File--settings--Tools--File Watcher. 9. Create a file called test.js and write es6 syntax in it, so no errors will be reported. test-compiled.js is a file compiled into es5, and the default is strict mode. I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website! Recommended reading:
How to add a progress bar to uploaded images in axios
How to optimize the JSON data grouping of JS
JS operates TXT text to insert content at the specified position
The above is the detailed content of How to use babel to convert ES6 to ES5 in Webstorm. For more information, please follow other related articles on the PHP Chinese website!

要使用 WebStorm 运行 Vue 项目,可以按照以下步骤进行操作:安装 Vue CLI创建 Vue 项目打开 WebStorm启动开发服务器运行项目查看浏览器中的项目在 WebStorm 中调试项目

对于入门JavaScript 开发的者,最重要的就是安装WebStorm软件,一款非常优秀的JavaScript工具,在互联网上查询目前还没有一篇写得比较详细的WebStorm教程。今天分享WebStorm2021.3.2版本的安装教程,从下载到安装以及创建项目带大家完整的走一遍。

使用 WebStorm 创建 HTML 项目分五步:创建新项目并配置 HTML 设置;添加新 HTML 文件;编写 HTML 代码并利用实时预览;预览 HTML 文件并进行部署;使用模板和 Emmet 快捷方式加快开发。

WebStorm 中切换中文方法:打开设置面板(Windows/Linux:Ctrl + Alt + S;macOS:Command + ,)。导航至“外观和行为”>“语言和框架”。在“用户界面语言”下拉菜单中选择“IntelliJ IDEA 用户界面”。在“Locale”列表中选择所需的中文语言(例如“中文(中国大陆)”)。点击“应用”,重启 WebStorm。

将 WebStorm 更改为中文版:打开 WebStorm 设置。导航到“Appearance & Behavior”>“Language & Fonts”。在“User Interface Language”中选择“Chinese (Simplified)”或“Chinese (Traditional)”。重启 WebStorm,界面将显示为中文。

要恢复 WebStorm 为默认设置,请关闭 WebStorm 并删除首选项目录,然后重新启动 WebStorm。详细步骤包括:完全退出 WebStorm。删除首选项目录(具体位置因操作系统而异)。重新启动 WebStorm。

使用 WebStorm 创建新项目的步骤:打开 WebStorm并选择“新建项目”;根据需要选择项目类型,如 Node.js、React 等;配置项目设置,包括名称、位置和框架版本;对于特定项目类型,选择所需框架;单击“创建”按钮生成项目;项目将自动在 WebStorm 中打开,供您编写代码和构建应用程序。

通过以下步骤在 WebStorm 中创建 Vue 项目:安装 WebStorm 和 Vue CLI。在 WebStorm 中创建一个 Vue 项目模板。使用 Vue CLI 命令创建项目。将现有项目导入 WebStorm。使用 "npm run serve" 命令运行 Vue 项目。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
