To install babel in your project, type in this command:
npm i -g babel-cli
Babel on its own doesn't do much. To get it to do something meaningful for you, you will need to install some additional presets. To convert ES6 into normal JS, you would use, like this.
npm i babel-preset-env
Let's say you have the following script in a file called, example.js'
If you run this command in the terminal:
babel example.js output.js
If you look on your file system, you should see that a new file called output.js has been created. If you look at this you will see your converted code.
If you were writing production code you wouldn't want to have to manually type in these commands, you would want to use babel with a tool like web-pack, so everything is automatically done for you. As you can see, babel is a very useful tool to ensure that your code works on all browsers. It's easy to install and get it working, so I would recommend that you give it a try today, enjoy!
Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge