Be the first user to complete this post

  • 0
Add to List

Use node in es6 syntax with babel transpiling

  • Install the following packages :
npm i --save babel-register
npm i --save babel-preset-latest
  • Create an entry point. For example, index.js
It transpiles your app at runtime by hooking into all require calls, and lets you start your app with regular Node.
require('babel-register');
require('./server/app.js');
  • Run the index file
node index.js

Further Reading :



Also Read:

  1. Dynamic module loading with require
  2. Configuring jshint as a pre-commit hook for your nodejs applications
  3. Organizing your expressjs routes in separate files.
  4. Error: can not find module 'underscore'
  5. webpack with babel6 and react
  6. Accessing the request body and session in nodejs using express
  7. exports is not defined
  8. Writing multiline sql queries in javascript using knex