Reputation: 29109
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 ?
Upvotes: 1
Views: 166
Reputation: 816364
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.
Upvotes: 1