1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Babelをコマンドラインから実行したい時

Last updated at Posted at 2017-11-07

babel-cliから単体でes6 -> es5 に落とす時に若干ハマったのでメモ。

$ npm install --save-dev babel-cli babel-preset-es2015
でインストール

注意

⚠️グローバルにインストールはしない⚠️
参照: http://babeljs.io/docs/usage/cli/

$ echo '{ "presets": ["es2015"] }' > .babelrc
で.babelrcができていることを確認

.babelrc
{ "presets": ["es2015"] }

適当にes6のコードを作成。

arrow-test.js
const x3 = (n) => n * 3

実行。

$ node_modules/.bin/babel arrow-test.js --presets es2015

"use strict";

var x3 = function x3(n) {
  return n * 3;
};
1
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?