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
相关推荐
excel38 分钟前
为什么我推荐使用 Termius:现代 SSH 工具的完整体验
前端·后端
ZC跨境爬虫44 分钟前
模块化烹饪小程序开发日记 Day7:(菜谱详情接口开发与JSON数据读取全流程)
前端·javascript·css·ui·微信小程序·json
এ慕ོ冬℘゜1 小时前
JS 前端基础面试题
开发语言·前端·javascript
LaughingZhu1 小时前
Product Hunt 每日热榜 | 2026-05-25
前端·人工智能·经验分享·chatgpt·html
IT_陈寒2 小时前
Java的Optional差点让我掉坑里,这几个坑你别踩
前端·人工智能·后端
粉嘟小飞妹儿2 小时前
JavaScript对象创建的几种灵活方法
前端
前端小万3 小时前
2026年了,为什么我突然开始做GZH?
前端
子兮曰3 小时前
Harness 驾驭工程深度教程:从 AGENTS.md 到全链路 AI 编码基础设施
前端·后端·ai编程
木子雨廷3 小时前
Flutter 桌面小组件开发
前端·flutter
还有多久拿退休金3 小时前
我在自家页面嵌了个 iframe,结果对方说"你不配"——跨域和 CSP 的那些坑
前端·架构