DEV Community

Cover image for Simple configuration Babel + Node
Evanderson Vasconcelos de Souza
Evanderson Vasconcelos de Souza

Posted on

2

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!

Sentry image

See why 4M developers consider Sentry, โ€œnot bad.โ€

Fixing code doesnโ€™t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay