how to install babel-cli babel-preset-react

1.7k Views Asked by At

I tried all possible way to install babel-cli babel-preset-react

Things I tried npm install --save-dev babel-cli babel-preset-react

but when I check babel -h

It shows The program 'babel' can be found in the following packages:

I refer this question also but doesn't work Babel command not found

1

There are 1 best solutions below

0
On BEST ANSWER

In order to run the babel command, you need to either install babel globaly or run it from package.json by saving it in scripts

scripts: {
   babelCmd: "babel src/app.js --out-file=public/scripts/app.js --presets=env,react --watch"
}

and run using

npm run babelCmd

If you want to run the babel command directly, you need to install like

npm install -g babel-cli babel-preset-react