My current test of Babel is simple.
require("babel-core/register");
import Twitter from "twitter";
I get the error SyntaxError: Unexpected token import
, which indicates that I have not gotten Babel to work correctly.
When running node index.js
it does not work. It does work when running babel-node index.js
I thought the require hook was supposed to allow ES6 to work at any time. If it only works when using babel-node, can someone explain why? Thank you!
My .babelrc file is
{
"presets": [
"es2015"
]
}
My dependencies in my package.json are
"dependencies": {
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-preset-es2015": "^6.3.13",
"babel-register": "^6.3.13",
"twitter": "^1.2.5"
}