ES6官网:https://262.ecma-international.org/6.0/
阮一峰ES6学习电子书:https://es6.ruanyifeng.com/#docs/let
W3Cschool ES6中文教程:https://www.w3cschool.cn/escript6/escript6-s4pc37et.html
菜鸟教程:https://www.runoob.com/w3cnote/es6-tutorial.html
//.babelrc文件中的内容
{
"presets": ["env"]
}
-y 的含义:yes的意思,在init的时候省去了敲回车的步骤,生成的默认的package.json
如果提示下面错误:无法将“babel”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。
babel报错解决方案:
//在package.json文件中增加build代码
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build":"babel src/index.js -o dist/index.js"
},
//执行npm run build
一般正常项目中babel会依托于webpack