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.