简体   繁体   中英

Do I still need babel with NodeJs5?

As far as I know node 5 supports ES2015, but when I try to run something like

import sizeOf from 'image-size';

I get

$>  node -v
v5.9.0
$> node test.js
/Users/dev/tmp/test.js:1
(function (exports, require, module, __filename, __dirname) { import sizeOf from 'image-size';
                                                              ^^^^^^

SyntaxError: Unexpected token import 
...

Now, when I search google, I find suggestions using babel (using a .babelrc with an es2015 preset), but if node5 supports ES2015, why do I need babel ?

if node5 supports ES2015, why do I need babel

Node doesn't support every feature of ES2015 yet. For the unsupported features you might want to use Babel, or simply not use the feature.

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