4

As Node V6 already supports ~95% of ES6, why are people using Babel on the server side? What are the pros and cons of using Babel on the server side?

Elankeeran
  • 6,134
  • 9
  • 40
  • 57
  • 1
    I'm quite sure it's ok to do but for the most part unnecessary. It may be a carry over from working with the browser and folks not realizing it's not needed on node. I can't say for sure though and hence this is a comment instead of an answer. – Frank V Feb 24 '17 at 15:26
  • Did [my answer](https://stackoverflow.com/questions/42442290/is-it-ok-to-use-babel-npm-package-for-node-js-server-application/42442403#42442403) below answer your question? Any comments? – rsp Jul 18 '17 at 17:20

1 Answers1

3

There is one main reason: import / export

See:

There is even a special Babel preset for Node:

that doesn't transpile anything that Node already supports natively.

You can also use babel-preset-env which is "A Babel preset that can automatically determine the Babel plugins and polyfills you need based on your supported environments" - thanks to loganfsmyth for pinting it out in the comments. See:

And Node doesn't support ES6 modules - see this answer for details on why:

Community
  • 1
  • 1
rsp
  • 107,747
  • 29
  • 201
  • 177