[英]How can I update all the packages inside the package.json and package-lock.json files?
I have a website and I haven't updated it for about a year.我有一个网站,大约一年没有更新它。 I need to update all the packages in "package.json" and "package-lock.json" and I have no clue how to do it.
我需要更新“package.json”和“package-lock.json”中的所有包,我不知道该怎么做。 I would be grateful for any suggestion.
我将不胜感激任何建议。 The Node version I'm using is 16.15.1 LTS.
我使用的 Node 版本是 16.15.1 LTS。
You can update packages in package.json
with these steps:您可以通过以下步骤更新
package.json
中的软件包:
1- Navigate to the root directory of your project and ensure it contains a package.json
file: 1- 导航到项目的根目录并确保它包含
package.json
文件:
cd /path/to/project
2- In your project root directory, run the update command: 2- 在您的项目根目录中,运行更新命令:
npm update
3-To test the update, run the outdated command. 3-要测试更新,请运行过时的命令。 There should not be any output.
不应该有任何 output。
npm outdated
And for package-lock.json
follow these steps:对于
package-lock.json
按照下列步骤操作:
1- Delete your package-lock.json
file in the root directory of your project, 1- 删除项目根目录中的
package-lock.json
文件,
2- Simply run npm install
as in default, it checks if your directory has package-lock.json
file otherwise, it will create one for you. 2- 只需运行
npm install
,它会检查您的目录是否有package-lock.json
文件,否则,它会为您创建一个。 (This command will honour the ^ and ~ symbol and update the packages to its latest that is provided by the library author(s)). (此命令将尊重 ^ 和 ~ 符号并将软件包更新到库作者提供的最新版本)。
Information about ^ and ~:关于 ^ 和 ~ 的信息:
In package.json
, a version can have a ^
in front (eg ^0.12.31), meaning the latest minor release may be safely installed.在
package.json
中,版本可以在前面有一个^
(例如 ^0.12.31),这意味着可以安全地安装最新的次要版本。
Tilde (~)
in front (eg, ~0.12.31) means the latest patch release is safe to install.前面的波浪号
(~)
(例如,~0.12.31)表示最新的补丁版本可以安全安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.