Reputation: 135
I'm using babel-node for execute this simple statement:
let obj = {};
But when i run, the following error appears:
SyntaError: repl: Only 'var' variables are supported in repl
I tried to run 'var' rather than 'let', but it appeared :
undefined
then i cannot access the variable
Upvotes: 2
Views: 1778
Reputation: 10454
This is because when using the babel-node
repl you must load the presets of your choice to activate their respective es2015 features.
To do so you need to run:
npm install babel-preset-es2015
Then when booting up the babel repl, you'll have to specify the presets:
babel-node --presets es2015
Now you can then use let obj = {}
Regarding the undefined
output, babel-node
and even the node
repl, this is expected and default behavior. Per the node REPL docs:
ignoreUndefined
- if set to true
, then the repl will not output the return value of command if it's undefined
. Defaults to false
.
This means that any anytime you invoke something in the repl, undefined
is returned.
Upvotes: 2