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
相关推荐
徐徐子几秒前
从vue3 watch开始理解Vue的响应式原理
前端·vue.js
眯眼因为很困啦3 分钟前
GitHub Fork 协作完整流程
前端·git·前端工程化
whisper6 分钟前
🚀 React Router 7 + Vercel 部署全指南
前端
还债大湿兄16 分钟前
huggingface.co 下载有些要给权限的模型 小记录
开发语言·前端·javascript
叶落无痕5216 分钟前
Electron应用自动化测试实例
前端·javascript·功能测试·测试工具·electron·单元测试
H@Z*rTE|i32 分钟前
elementUi 当有弹窗的时候提示语被覆盖的问题
前端·javascript·elementui
阿奇__33 分钟前
vue2+elementUI table多个字段排序
前端·javascript·elementui
hellokatewj1 小时前
React Hooks 全解:原理、API 与应用场景
前端·javascript·react.js
袋鱼不重1 小时前
保姆级教程:让 Cursor 编辑器突破地区限制,正常调用大模型(附配置 + 截图)
前端·后端·cursor
bieao1 小时前
Vite+Antd+Micro-app中iframe模式下样式闪烁的问题
前端