1

I know that Node.js fully supports ES6 by now, (using nodejs 7.2.1). I've been told by someone that the ES6 implementation of Node.js isn't production ready and I must have Babel for a production ready ES6.

I read babeljs.io and it's a JavaScript compiler for old browsers that don't support ES6.

I'm a bit confused. Does Node.js need Babel to compile to ES5? Or can I use Node.js with ES6? is it production ready? Do I really need Babel with Node.js at all?

Michał Perłakowski
  • 88,409
  • 26
  • 156
  • 177
ufk
  • 30,912
  • 70
  • 235
  • 386
  • It depends on what features you need. Most ES2015 features are available and stable. ES6 modules are not there. – Estus Flask Dec 11 '16 at 09:33
  • What you need according to the http://kangax.github.io/compat-table/es6/ ? Or you can compare your requirements with http://node.green – Krzysztof Safjanowski Dec 11 '16 at 11:02
  • You shouldn't use babel for node in production, it can negatively impact your performance because of the way in which babel works. Read more in this thread: http://stackoverflow.com/questions/30773756/is-it-okay-to-use-babel-node-in-production. The node implementation of ES6/2015 is actually production ready since it's natively built into V8. – Alex Moldovan Dec 11 '16 at 11:13

1 Answers1

5

The latest Node.js version supports almost all ES6 features except modules. However, if you're for example developing a library for Node.js, many people using it may not have the latest version of Node. If you don't know where your package will be used, you should use the es2015 preset. If you know that your package will be used only in Node.js 7.x, you can use babel-preset-node7.

Michał Perłakowski
  • 88,409
  • 26
  • 156
  • 177