An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
May 14, 2021 09:43 pm GMT
Original Link: https://dev.to/muhammadiqbal/run-node-js-app-with-es6-features-59o3
Run Node.js app with ES6 features
In this article, we will learn how to use ES6 syntax to write your Node Server in few simple steps.
Installing babel as dev dependencies in the project
Babel is a toolchain that is mainly used to convert ECMAScript 2015+
code into a backward-compatible version of JavaScript in current and
older browsers or environments. Here are the main things Babel can do
for you:
Installation with npm
npm install --save-dev @babel/core @babel/node @babel/preset-env
Installation with yarn
yarn add @babel/core @babel/node @babel/preset-env -D
After successful installations of dev-dependencies create a file named .babelrc like this.
and paste the following code in it and save the .babelrc file.
{ "presets": ["@babel/preset-env"]}
Running the ES6 Code
Now you can run your node.js project with ES6 features by running the following command.
yarn babel-node index.jsornpx babel-node index.js
That is it for this short article.
I am writing this first time please forgive me for my mistakes. I hope you guys find it informative.
Original Link: https://dev.to/muhammadiqbal/run-node-js-app-with-es6-features-59o3
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To