Simple configuration Babel + Node

evandersonvasconcelos

Evanderson Vasconcelos de Souza

Posted on June 8, 2020

Simple configuration Babel + Node

Hello, I'm Evanderson, this is my second post and this I will you go to teach how to configure the Babel + Node in a simple way, let's go!


🚀 First step:

  • Initialize your papckage.json
yarn init -y

or

npm init -y

📂 Install devDependecies:

yarn add babel-cli babel-preset-env nodemon rimraf -D

  or

npm install --save-dev babel-cli babel-preset-env nodemon rimraf

📄 Create file .babelrc in root path:

  • Insert the code:
{
  "presets": [
    ["env", {
      "node": "current"
    }]
  ]
}

📄 Create three scripts in package.json:

"scripts": {
  "dev": "nodemon -w src --exec \"babel-node src --presets env\"",
  "build": "rimraf build && babel src -s -D -d build --presets env",
    "start": "node build"
}

obs ⚠: In your project you should have a folder src and a file index.js into the folder, if not, you should configure the package.json in accord with your directories.


💻 It's already done:

  • With this simple configuration, you can use import/export and several actualities of the syntax

if did you like, comment and share ok? bye!

💖 💪 🙅 🚩
evandersonvasconcelos
Evanderson Vasconcelos de Souza

Posted on June 8, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

What was your win this week?
weeklyretro What was your win this week?

November 29, 2024

Where GitOps Meets ClickOps
devops Where GitOps Meets ClickOps

November 29, 2024

How to Use KitOps with MLflow
beginners How to Use KitOps with MLflow

November 29, 2024