ufk
ufk

Reputation: 32144

Do I have to use Babel in Node.js?

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?

Upvotes: 1

Views: 2773

Answers (1)

Michał Perłakowski
Michał Perłakowski

Reputation: 92719

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.

Upvotes: 6

Related Questions