简体   繁体   English

Babel:CLI已被移入“babel-cli”包中

[英]Babel: The CLI has been moved into the package `babel-cli`

I was working on a JS file at work where I had babel installed, running babel file.js | node 我正在工作的JS文件,我安装了babel,运行babel file.js | node 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: babel file.js | node我晚上把文件送回家工作,在家里安装了babel,当我运行上面的命令时出现以下错误:

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: 如果我安装CLI - 以下代码无法编译:

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;
}

Babel version 6 split the project into several modules. Babel版本6将项目分成几个模块。 As the message indicates the CLI has moved to babel-cli . 正如消息所示,CLI已移至babel-cli

I suggest you use the same version that you use at work (which is probably v5): 我建议你使用你在工作中使用的相同版本(可能是v5):

npm install -g babel@5

However, if you would rather use the latest version: 但是,如果您更愿意使用最新版本:

npm install -g babel-cli

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM