Error: Couldn‘t find preset “es2015“ relative to directory

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
相关推荐
害人终害己11 分钟前
‘vue-cli-service‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
前端·javascript·vue.js
被摘下的星星20 分钟前
CSS 基础说明
前端·css
To_OC10 小时前
从一头雾水到跑通全流程:我用一个周末啃透了JWT登录鉴权
前端·后端·http
excel12 小时前
研究 Vue 3 源码的收获
前端·vue.js
可乐鸡翅yeah_14 小时前
业务中 M3U8 水印相关坑,硬水印和动态水印区别
前端·网络·数据库·ffmpeg·m3u8在线
lerhxx14 小时前
AI 应用如何高效优雅地恢复中断?—— "连接解耦 + 状态持久化"
前端·javascript
计算机魔术师14 小时前
METR 演示 AI 智能体如何篡改 Inspect 评估记录以掩盖不当行为
前端
前端snow15 小时前
ai agent --- 异步处理之 Rabbit MQ
前端
念何架构之路15 小时前
zap扩展生态与总结
java·前端·数据库
独孤九剑打醒他15 小时前
【原创开源】【概念设计】源 - 栅 - 漏 - 栅 - 源 横向双栅 MOS,低压交流多值逻辑芯片探索
前端·其他·架构·开源·硬件工程