vue引入element-ui,运行时报了这个错误
Module build failed: Error: Couldn't find preset "es2015" relative to directory "D:\\360MoveData\\Users\\Administrator\\Desktop\\新建文件夹\\henge-test"
at D:\360MoveData\Users\Administrator\Desktop\新建文件夹\henge-test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:293:19
at Array.map (<anonymous>)
at OptionManager.resolvePresets (D:\360MoveData\Users\Administrator\Desktop\新建文件夹\henge-test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
at OptionManager.mergePresets (D:\360MoveData\Users\Administrator\Desktop\新建文件夹\henge-test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
at OptionManager.mergeOptions (D:\360MoveData\Users\Administrator\Desktop\新建文件夹\henge-test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
at OptionManager.init (D:\360MoveData\Users\Administrator\Desktop\新建文件夹\henge-test\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (D:\360MoveData\Users\Administrator\Desktop\新建文件夹\henge-test\node_modules\babel-core\lib\transformation\file\index.js:212:65)
at new File (D:\360MoveData\Users\Administrator\Desktop\新建文件夹\henge-test\node_modules\babel-core\lib\transformation\file\index.js:135:24) at Pipeline.transform (D:\360MoveData\Users\Administrator\Desktop\新建文件夹\henge-test\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
at transpile (D:\360MoveData\Users\Administrator\Desktop\新建文件夹\henge-test\node_modules\babel-loader\lib\index.js:50:20)
at Object.module.exports (D:\360MoveData\Users\Administrator\Desktop\新建文件夹\henge-test\node_modules\babel-loader\lib\index.js:173:20)
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
按照element-ui中的步骤 把.babelrc 文件内容从
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"]
}
更改为了
{
"presets": [["es2015", { "modules": false }]],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
然后运行时就报了这个问题
解决方案:
安装es2015 工具
npm install --save-dev babel-preset-es2015