I was working on a JS file at work where I had babel installed, running babel file.js | node
I sent the file home to work in the evening, installed babel at home and I got the following error when I run the above command:
The CLI has been moved into the package 'babel-cli'
Any ideas? Thank you in advance :)
If I install the CLI - the following code fails to compile:
function sumArrayIndex(array, i, separator) {
return array
.map(x => x.split(separator)
.map(c => { return parseInt(c) })
)
.map(x => { return x[i]; })
.reduce((x, y) => { return x += y }, 0);
}
function minToSec(m) {
return m * 60
}
function secondsToMinutesAndSeconds(s) {
var min = s / 60;
var sec = s % 60;
minutes += Math.floor(min);
seconds += sec;
}
function outputTime() {
return hours + ':' + minutes + ':' + seconds;
}
You can also check the version of babel-cli by finding the babel-cli folder in node_modules and looking at the version property of the package. json that is at the base of that folder. If babel-cli was installed globally via -g flag of npm install , you could check the version by executing command babel --version .
Babel comes with a built-in CLI which can be used to compile files from the command line. In addition, various entry point scripts live in the top-level package at @babel/cli/bin . There is a shell-executable utility script, babel-external-helpers. js , and the main Babel cli script, babel.
Babel version 6 split the project into several modules. As the message indicates the CLI has moved to babel-cli
.
I suggest you use the same version that you use at work (which is probably v5):
npm install -g babel@5
However, if you would rather use the latest version:
npm install -g babel-cli
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With