简体   繁体   中英

Is it ok to use Babel npm package for node.js server application

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?

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM