ElementUI / babel-plugin-component

Modular element-ui build plugin for babel.
450 stars 95 forks source link

按需引入官方问题配置出错 #68

Open AdamEva916 opened 1 year ago

AdamEva916 commented 1 year ago

第一个问题 Error: Cannot find module 'babel-preset-es2015' Require stack:

第二个问题 Error: .plugins[0][1] must be an object, false, or undefined Error: .plugins[0][1] must be an object, false, or undefined at validate (F:\vue\dev\dev\node_modules\@babel\core\lib\config\validation\options.js:86:25) at F:\vue\dev\dev\node_modules\@babel\core\lib\config\config-chain.js:165:34 at cachedFunction (F:\vue\dev\dev\node_modules\@babel\core\lib\config\caching.js:48:27) at cachedFunction.next () at evaluateSync (F:\vue\dev\dev\node_modules\gensync\index.js:251:28) at sync (F:\vue\dev\dev\node_modules\gensync\index.js:89:14) at buildRootChain (F:\vue\dev\dev\node_modules\@babel\core\lib\config\config-chain.js:77:27) at buildRootChain.next () at loadPrivatePartialConfig (F:\vue\dev\dev\node_modules\@babel\core\lib\config\partial.js:79:62) at loadPrivatePartialConfig.next ()

旧配置项 { "presets": [["es2015", { "modules": false }]], "plugins": [ [ "component", { "libraryName": "element-ui", "styleLibraryName": "theme-chalk" } ] ] }

大佬们能不能改改官方文档,按需文档一步步走真的出错,不好找原因

purer01 commented 9 months ago

我也遇到了相同的问题,可以将配置项里的"presets": [["es2015", { "modules": false }]],修改为:"presets": [["@babel/preset-env", { "modules": false }]],应该就可以解决。 原因:看报错内容应该与你的babel版本有关系(终端执行babel --version即可查看babel的版本号),对于babel 6来说,使用的就是babel-preset-es2015,但如果对于babel 7来说,应该使用的是@babel/preset-es2015。 从报错看出你使用的应该是7这个版本,对于7来说,babel-preset-es2015已经废弃了。