简体   繁体   English

如何更新警告已弃用

[英]how to update warn deprecated

I'm trying to learn node and npm, using express for a little project.我正在尝试学习节点和 npm,将 express 用于一个小项目。 When i install it, i got当我安装它时,我得到了

npm WARN deprecated core-js@2.6.10: core-js@<3.0 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.

I understood that if everything works, it's not necessary to update everything, but i'm trying to learn and go the extra, unnecessary, mile.我知道如果一切正常,就没有必要更新所有内容,但我正在努力学习 go 额外的、不必要的英里。

How can i update only core-js?我怎样才能只更新 core-js?

npm install core-js@^3

will update it adding it to the dependencies in package.json.将更新它,将其添加到 package.json 中的依赖项中。

Is this the right way to do it?这是正确的方法吗? Or it's better to update the parent package that use it?或者最好更新使用它的父 package? If so, how can i understand which is the package that need an update and how to update it?如果是这样,我如何了解需要更新的 package 以及如何更新它? Or is there a way to update only the modules listed in package-lock.json.或者有没有办法只更新 package-lock.json 中列出的模块。

Thanks.谢谢。

You provided one way to update a package.您提供了一种更新软件包的方法。 However, there are a few more.但是,还有一些。

To update a global package, you could run:要更新全局包,您可以运行:

npm update -g <package_name>

To update a package that's in your package.json (ie, local to your project), run:要更新package.json中的package.json (即项目的本地package.json ),请运行:

npm update <package_name>

You could also see what outdated package are there as follows:您还可以查看有哪些过时的软件包,如下所示:

npm outdated

You could again add -g option to check outdated global packages.您可以再次添加-g选项来检查过时的全局包。

Sources: https://docs.npmjs.com/updating-packages-downloaded-from-the-registry来源: https : //docs.npmjs.com/updating-packages-downloaded-from-the-registry

Also: man npm may help (in Linux).另外: man npm可能会有所帮助(在 Linux 中)。

To update to a new major version all the packages, install the npm-check-updates package globally:要将所有软件包更新到新的主要版本,请全局安装 npm-check-updates package:

npm install -g npm-check-updates

this will upgrade all the version hints in the package.json file, to dependencies and devDependencies, so npm can install the new major version.这会将 package.json 文件中的所有版本提示升级为 dependencies 和 devDependencies,因此 npm 可以安装新的主要版本。

You are now ready to run the update:您现在可以运行更新了:

npm update

or npm installnpm install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM