Configure Babel for Node

@babel/core: A fundamental package to run any babel setup/configuration.
@babel/cli:A built-in CLI which can be used to compile files from the command line/terminal.
@babel/node:is a CLI that works the same as the Node.js CLI, with the added benefit of compiling with Babel presets and plugins before running it.
@babel/preset-env(dev): is a smart preset that allows you to use the latest JavaScript .
@babel/plugin-transform-runtime(dev):A plugin that enables the re-use of Babel's injected helper code to save on code size.
@babel/runtime(save): a package to be installed production dependency to avoid duplication across your compiled output.
  
// yarn add 
@babel/node @babel/preset-env @babel/plugin-transform-runtime @babel/runtime
    
// .babelrc
{
  "presets": ["@babel/preset-env"],
  "plugins": [
    ["@babel/plugin-transform-runtime"]
  ]
}

// package.json
"scripts": {
    "start": "npm run build && node ./build/src/server.js",
    "dev": "nodemon --exec babel-node ./src/server.js",
    "clean": "rm -rf build && mkdir build",
    "build-babel": "babel ./src -d ./build/src",
    "build": "npm run clean && npm run build-babel"
}

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source