CLI · Babel


Babel comes with a built-in CLI which can be used to compile files from the command line.

While you can install Babel CLI globally on your machine, it’s much better to install it locally project by project.

This is a companion discussion topic for the original entry at


Hello Babel Team ! Could you teach me how to understand this sentence: “ES6-style module-loading may not function as expected”



For example:

$ babel-node
> var uuid = require("uuid");
> uuid.v4();
> import v4 from "uuid";
SyntaxError: repl: Modules aren't supported in the REPL
> 1 | import v4 from "uuid";
    | ^
    at File.buildCodeFrameError (/home/user/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:431:15)
    at NodePath.buildCodeFrameError (/home/user/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/index.js:140:26)
    at PluginPass.ModuleDeclaration (/home/user/lib/node_modules/babel-cli/lib/_babel-node.js:75:20)
    at newFn (/home/user/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/home/user/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:76:18)
    at (/home/user/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/home/user/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/path/context.js:105:12)
    at TraversalContext.visitQueue (/home/user/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitMultiple (/home/user/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:103:17)
    at TraversalContext.visit (/home/user/lib/node_modules/babel-cli/node_modules/babel-traverse/lib/context.js:190:19)


Not saying it would still work but wouldn’t the import syntax be:

import { v4 } from "uuid";


@eudaimos yes, the correct ES6 syntax is import {v4} from "uuid"; .

I’ve just checked this syntax on babel-node and it fails with the same error message.


Is there a way to specify preset options (like {"modules": false}) using babel-cli only ?
It means without using .babelrc


node_modules.bin\babel script.js


How do you use rlwrap? I can’t find it on npm.