0

I am trying to use babel to transpile ES6, but it's not working. I'm doing a very basic example, so here must be something obvious I am missing.

I installed babel via npm:

$ npm install -g babel-cli

My file, test.js:

const input = [1, 2, 3];
console.log(input.map(item => item + 1)); // [2, 3, 4]

The command I'm running:

$ babel test.js

And the output:

const input = [1, 2, 3];
console.log(input.map(item => item + 1)); // [2, 3, 4]

Note that it's unchanged. I expect it to be transpiled...what could be going on here?

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
Sam Lee
  • 9,913
  • 15
  • 48
  • 56
  • Already answered--see documentation for Babel 6. Try something like `$ npm install --save-dev babel-cli babel-preset-es2015`. –  Nov 11 '15 at 01:13
  • Could you point me to the docs on this? The install page just says `$ npm install babel-cli` (here: https://babeljs.io/docs/setup/) – Sam Lee Nov 11 '15 at 01:20
  • Also, `$ npm install -g babel-cli babel-preset-es2015` doesn't seem to work either... – Sam Lee Nov 11 '15 at 01:23
  • 1
    See http://stackoverflow.com/questions/33440405/babel-file-is-copied-without-being-transformed. –  Nov 11 '15 at 01:59
  • This question is literally asked multiple times a day. It shouldn't be too hard to use the search and find a solution before asking a new question. – Felix Kling Nov 11 '15 at 14:14
  • The documentation is wrong and search did not bring up anything. Emperically, since it's being asked multiple times a day, it *is* hard to find a solution – Sam Lee Nov 11 '15 at 18:06

0 Answers0