cmd
npm install
{
“name”: “babel”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo \”Error: no test specified\” && exit 1″
},
“author”: “”,
“license”: “ISC”,
“devDependencies”: {
“@babel/cli”: “^7.14.3”,
“@babel/core”: “^7.14.3”
}
}
以上改为如下:
{
“name”: “babel”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“build”: “babel src -d dist”
},
“author”: “”,
“license”: “ISC”,
“devDependencies”: {
“@babel/cli”: “^7.14.3”,
“@babel/core”: “^7.14.3”
}
}
在根目录下新建
/src/
/src/babel.js
/dist/
npm install @babel/preset-env –save-dev
/src/.babelrc
执行如下命令: npm run build 会自动建 /dist/ 目录