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

5
  • 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 Commented May 16, 2018 at 9:10
  • package.json this is my package.json file. And I tried babel -h but same error
    – Mohsin
    Commented May 16, 2018 at 9:15
  • Since you write babel in script, you would use npm run babel -h Commented May 16, 2018 at 9: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
    Commented May 16, 2018 at 9:19
  • if babel is install then why i am getting this error The program 'babel' can be found in the following packages:
    – Mohsin
    Commented May 16, 2018 at 9:22

1 Answer 1

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
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.