Nelu
Nelu

Reputation: 18710

How to compile and run an ES6 file with node when using babel6?

I installed the latest version 6 of babel, babel-core and babel-loader.

How can I run an ES6 file in Node with Babel6?

Previously I would run the command

babel-node server.js

but now I get this message:

The CLI has been moved into the package `babel-cli`. See http://babeljs.io/docs/usage/cli/.

None of the instructions on that page say how to do this.

Upvotes: 0

Views: 763

Answers (2)

Nelu
Nelu

Reputation: 18710

Upon installing babel-cli I also had to specify the es2015 loader and to specifically use my local babel-node package since I don't have it installed globally.

./node_modules/.bin/babel-node --presets es2015 server.js

Upvotes: 1

loganfsmyth
loganfsmyth

Reputation: 161457

The message could be clearer. You've installed the babel package and you should have installed the babel-cli package.

npm uninstall babel
npm install babel-cli

Upvotes: 1

Related Questions