2

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

Mohsin
  • 199
  • 5
  • 19
  • 1
    have you saved it in a local directory which contains package.json, if yes, then try adding `babel -h` inside scripts in package.json `babelh: babel -h` and run using `npm run babelh` – Shubham Khatri May 16 '18 at 09:10
  • [package.json](https://i.imgur.com/sm4s3Nh.png) this is my package.json file. And I tried `babel -h` but same error – Mohsin May 16 '18 at 09:15
  • Since you write babel in script, you would use `npm run babel -h` – Shubham Khatri May 16 '18 at 09:18
  • yes I wrote now it is running `babel -h` this command. but this not working `babel src/app.js --out-file=public/scripts/app.js --presets=env,react --watch` – Mohsin May 16 '18 at 09:19
  • if babel is install then why i am getting this error `The program 'babel' can be found in the following packages:` – Mohsin May 16 '18 at 09:22

1 Answers1

4

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
Shubham Khatri
  • 270,417
  • 55
  • 406
  • 400