A simple example of using babel to convert es6 syntax to es5, babeles6 syntax es5

Source: Internet
Author: User
Tags install node

A simple example of using babel to convert es6 syntax to es5, babeles6 syntax es5

Preface

Babel is a widely used Transcoder that can convert ES6 code into ES5 code for execution in an existing environment.

This means that you can write programs in ES6 now without worrying about the support of the existing environment.

This article describes how to pre-install node and npm. For more information, see http://www.bkjia.com/article/90518.htm.

File directory structure


Generate package management configuration file package. json

Npm init-y

Install Conversion Tool

Npm I-g babel-clinpm I -- save-dev babel-preset-es2015 babel-cli

Write the following content in the. babelrc file:

{"Presets": ["es2015"], "plugins": []}

Compile a file

Babel src/test. js-o dist/test. js

Summary

The above is all the content of this article. I hope the content of this article has some reference and learning value for everyone's learning or work. If you have any questions, please leave a message to us, thank you for your support.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.