When importing elementUI globally, it always reports an error saying that no dependencies related to core-js can be found, similar to: core-js/library/fn/object/assign in ./node_modules/babel-runtime/core-js/object/assign.js , I found a lot of solutions, and the final effective solution is as follows:
First, upgrade core-js and execute the command npm install core-js@3 --save
Then execute npm install [email protected] --save
Restart the project, the error disappears
If there is no effect, then execute npm i -D babel-plugin-component
Configure the .babelrc file, if there is no such file, create one in the root directory of the project
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": 3
}
]
],
"plugins": [
[ "component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
Reference article: Vuepress reports an error when loading element-ui Cannot find module 'core-js/library/fn/object/assign_Endless bug blog-CSDN blog