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
相关推荐
zhangxingchao5 分钟前
AI大模型核心八:从 Agent Skill、长文档 RAG 到知识库更新与训练策略
前端·人工智能·后端
zhangxingchao34 分钟前
AI大模型核心七:从 Workflow、RAG、记忆治理到幂等性
前端·人工智能·后端
gyx_这个杀手不太冷静1 小时前
Agent开发进阶指南(第 1 章):AI Agent 到底是什么?
前端·agent·ai编程
小小小小宇2 小时前
模型相关知识
前端
小小小小宇2 小时前
模型相关知识二
前端
IT_陈寒2 小时前
Python装饰器竟然偷偷改了函数名?这个坑我爬了三天
前端·人工智能·后端
Momo__3 小时前
Vite 8.1 打包开发模式——10000 组件冷启动 15 倍,"No Bundle Dev" 七年后被自己终结
前端·vue.js·vite
YHL3 小时前
🤖 Agent 智能体开发实战 · 第一课:Tool Use —— 让大模型自动干活
前端·javascript·人工智能
Monki3 小时前
AI 规范式 UI 设计,一键批量出页,高效落地不翻车
前端
山河木马3 小时前
渲染管线-计算得到gl_FragColor(片元着色器)之后续GPU流程
前端·webgl·计算机图形学