Rohith K Gorantla
Rohith K Gorantla

Reputation: 55

babel-cli not working as expected

I had installed babel-cli globally using npm. And I had a script.js file which contains the ES6 code. When I tried to compile that using $babel script.js -o out.js, it just copy all the contains of the script.js to out.js.

As far I concern, it should convert all the ES6 code to ES5.

Even if I run the script.js file without any content, it should show "use strict"; in my out.js. But it shows an empty file. Unable to figure out whats wrong?

Moreover I am unable to understand why "https://www.npmjs.com/package/babel-cli" says to install babel-cli globally where as "https://babeljs.io/docs/setup/#babel_cli" says to install that locally.

When I installed babel-cli locally and try to compile the script.js file it simply shows

'babel' is not recognized as an internal or external command, operable program or batch file.

Upvotes: 3

Views: 4982

Answers (3)

Neel Patel
Neel Patel

Reputation: 2176

First Go to main directory or open new terminal

step 1: go to main directory

open terminal or (type cd so that you can directly switch in main directory)

step 2 : npm install -g babel-cli

now successfully install babel cli in your machine

Upvotes: 1

Anand Tiwari
Anand Tiwari

Reputation: 77

npm install -g babel-cli

It works.

Upvotes: 0

madhu kiran
madhu kiran

Reputation: 31

This should answer your question worked for me. https://github.com/babel/babel/issues/4066

or install babel-cli globally and try it works then.

Upvotes: 3

Related Questions