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 backwa…


This content originally appeared on DEV Community and was authored by Muhammad Iqbal

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:

  • Transform syntax
  • Polyfill features that are missing in your target environment (through a third-party polyfill such as core-js)
  • Source code transformations (codemods)
  • And more! (check out these videos for inspiration)

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.

.babelrc-file
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.js
or
npx 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.


This content originally appeared on DEV Community and was authored by Muhammad Iqbal


Print Share Comment Cite Upload Translate Updates
APA

Muhammad Iqbal | Sciencx (2021-05-14T21:43:55+00:00) Run Node.js app with ES6 features. Retrieved from https://www.scien.cx/2021/05/14/run-node-js-app-with-es6-features/

MLA
" » Run Node.js app with ES6 features." Muhammad Iqbal | Sciencx - Friday May 14, 2021, https://www.scien.cx/2021/05/14/run-node-js-app-with-es6-features/
HARVARD
Muhammad Iqbal | Sciencx Friday May 14, 2021 » Run Node.js app with ES6 features., viewed ,<https://www.scien.cx/2021/05/14/run-node-js-app-with-es6-features/>
VANCOUVER
Muhammad Iqbal | Sciencx - » Run Node.js app with ES6 features. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/14/run-node-js-app-with-es6-features/
CHICAGO
" » Run Node.js app with ES6 features." Muhammad Iqbal | Sciencx - Accessed . https://www.scien.cx/2021/05/14/run-node-js-app-with-es6-features/
IEEE
" » Run Node.js app with ES6 features." Muhammad Iqbal | Sciencx [Online]. Available: https://www.scien.cx/2021/05/14/run-node-js-app-with-es6-features/. [Accessed: ]
rf:citation
» Run Node.js app with ES6 features | Muhammad Iqbal | Sciencx | https://www.scien.cx/2021/05/14/run-node-js-app-with-es6-features/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.