简体   繁体   English

如何安装 babel-cli babel-preset-react

[英]how to install babel-cli babel-preset-react

I tried all possible way to install babel-cli babel-preset-react我尝试了所有可能的方法来安装babel-cli babel-preset-react

Things I tried npm install --save-dev babel-cli babel-preset-react我试过的事情npm install --save-dev babel-cli babel-preset-react

but when I check babel -h但是当我检查babel -h

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

I refer this question also but doesn't work Babel command not found我也提到了这个问题,但不起作用Babel command not found

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为了运行 babel 命令,您需要全局安装 babel 或通过将其保存在脚本中从package.json运行它

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如果想直接运行babel命令,需要像这样安装

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM