1. 安装 babel es6 依赖包
npm i --save-dev nodemon
npm i --save-dev babel-cli
npm i --save-dev babel-plugin-transform-async-generator-functions
npm i --save-dev babel-plugin-transform-object-rest-spread
npm i --save-dev babel-plugin-transform-runtime
npm i --save-dev babel-preset-latest
2. 编写 .babelrc
{
"presets": ["latest"]
}
3. 编写 npm scripts
"scripts": {
"start": "nodemon ./src/your-es6-code.js --exec babel-node -e js"
},
执行
npm start
网友评论