even

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1、安装babel-cli

npm i babel-cli -D

2、实现npm的初始化

npm init -y

3、配置package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "babel src -d lib"    //src  表示需要转换的文件夹,lib表示转换后的目标文件夹
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

4、安装版本文件

npm i babel-preset-env -D

5、创建 .babelrc 配置文件

{
  "presets": ["env"]
}

6、实现转换

npm run build

 

posted on 2018-09-15 23:02  even_blogs  阅读(334)  评论(0编辑  收藏  举报