Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AdamEva916 opened this issue Mar 17, 2023 · 1 comment
Open

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

AdamEva916 opened this issue Mar 17, 2023 · 1 comment

Comments

@AdamEva916
Copy link

第一个问题
Error: Cannot find module 'babel-preset-es2015'
Require stack:
- F:\vue\dev\dev\node_modules@babel\core\lib\config\files\plugins.js
- F:\vue\dev\dev\node_modules@babel\core\lib\config\files\index.js
- F:\vue\dev\dev\node_modules@babel\core\lib\index.js
- F:\vue\dev\dev\node_modules@vue\cli-plugin-babel\index.js
- F:\vue\dev\dev\node_modules@vue\cli-service\lib\Service.js

第二个问题
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
Copy link

purer01 commented Dec 17, 2023

我也遇到了相同的问题,可以将配置项里的"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已经废弃了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants