ES 之 babel

//初始化
npm init -y


npm install --save-dev @babel/core @babel/cli @babel/preset-env

安装转换插件

npm install --save-dev @babel/plugin-transform-arrow-functions

package.json

"scripts": {
    "babel": "babel app.js --watch --out-file app-complied.js"
  },
  "devDependencies": {
    "@babel/cli": "^7.8.4",
    "@babel/core": "^7.8.4",
    "@babel/plugin-transform-arrow-functions": "^7.8.3",
    "@babel/preset-env": "^7.8.4"
  },
  "babel":{
    "plugins": [
      ["@babel/plugin-transform-arrow-functions"]
    ]
  }

npm run babel

相关推荐