Error: Please, upgrade your dependencies to the actual version of core-js@3

Error: Please, upgrade your dependencies to the actual version of core-js@3

我正在尝试 运行 npm start 但出现错误 "An unhandled exception occurred: Could not find module "@angular-devkit/build-angular" 我也尝试使用 npm install @angular-devkit/build-angular 安装它但是仍然给我一个错误。

错误"npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3."

如何升级我的依赖项?

您应该能够简单地更新警告消息中请求的 core-js 模块的版本:

npm install --save core-js@^3

值得一提的是 npm 有一个很棒的功能,可以让你看到哪些包是 outdated

npm outdated

您还可以使用 update 命令将软件包更新到最新版本

您可以运行'npm audit fix',这将更新导致更新和版本错误的依赖项

以下步骤解决了我的问题,

npm i --package-lock-only
npm audit fix

--package-lock-only 这将确定要使用 package.json 安装的软件包版本,然后创建一个 package-lock.json 文件如果 none 存在,则它的解析版本,或者覆盖现有版本。

审核修复 扫描您的项目中的漏洞并自动为易受攻击的依赖项安装任何兼容更新

More Information Here

这解决了我的问题

$ npm ci

我对过时的依赖项有类似的问题。我执行了以下步骤并且对我有用:

npm uninstall -g angular-cli @angular/cli

npm cache clean --force

npm outdated (to check all the outdated dependency)

npm update

最后转到包含您的项目的文件夹,然后运行此命令:

npm install -g @angular/cli