vue.js:node_modules/_babel-runtime@6.26.0@babel-runtime/core-js/object/assign.js

2023-01-08 19:17:33

我的项目依赖

package.json

{
  "dependencies": {
    "element-ui": "2.15.1",
    "vue": "2.6.10",
  },
  "devDependencies": {
    "@vue/cli": "4.5.19",
    "@vue/cli-service-global": "4.5.19"
  }
}

运行单文件开发

$ npx vue serve

报错

ERROR  Failed to compile with 3 errors                                      2:32:02 PM

These dependencies were not found:

* core-js/library/fn/object/assign 
in ./node_modules/_babel-runtime@6.26.0@babel-runtime/core-js/object/assign.js
* core-js/library/fn/symbol 
in ./node_modules/_babel-runtime@6.26.0@babel-runtime/core-js/symbol.js
* core-js/library/fn/symbol/iterator 
in ./node_modules/_babel-runtime@6.26.0@babel-runtime/core-js/symbol/iterator.js

To install them, you can run: npm install --save 
core-js/library/fn/object/assign 
core-js/library/fn/symbol 
core-js/library/fn/symbol/iterator

解决办法

npm install core-js@3 --save
npm install async-validator@1.11.5 --save
npm i -D babel-plugin-component

配置 .babelrc

{
  "presets": [
    [
      "@babel/preset-env", 
      {
        "useBuiltIns": "usage",
        "corejs": 3 
      }
    ]
  ],
  "plugins": [
    [ "component",
      {
      "libraryName": "element-ui",
      "styleLibraryName": "theme-chalk"
      }
      ]
  ] 
}

参考
elementUI报错找不到依赖 core-js/library/fn/object/assign in ./node_modules/babel-runtime/core-js/object/ass

  • 作者:彭世瑜
  • 原文链接:https://pengshiyu.blog.csdn.net/article/details/126643332
    更新时间:2023-01-08 19:17:33