当前位置:网站首页>package.json and package-lock.json
package.json and package-lock.json
2022-08-02 12:34:00 【m0_67400972】
package.json
Record the version information of the modules that the current project depends on, lock the major version number of the module (the first part of the version number) when updating the module, and cannot lock the subsequent minor version,
package-lock.json
package-lock.json is a file generated during `npm install`.Records the names, version numbers, download addresses, and dependencies of all modules (packages) in the node_modules directory.
The difference between the two:
before npm5
Before npm5, there was no package-lock.json file.The package.json file will record all the modules you need in your project.When you execute npm install, node will first read all the dependencies information from the package.json file, and then compare the information in the dependencies with the modules in node_modules, if there is no direct download, and the existing ones will be checked for updates.
Because package.json can only lock the major version number of the module (the first part of the version number), it cannot lock the subsequent minor version, so every time you re-npminstall, you will pull the latest version under the major version.Generally, we cannot upgrade dependent packages at will for the sake of stability, because it is difficult to troubleshoot compatibility bugs caused by changing packages, which is prone to problems, so package-lock.json is to solve the problem of package locking and not upgrading
In addition, the package.json file only records the information of the modules you installed through npm install, and the information of other submodules that these modules depend on will not be recorded.
After npm5
The package-lock.json file locks the version numbers of all modules, including the main module and all dependent submodules.When you run npm install, node reads the module name from the package.json file, gets the version number from the package-lock.json file, and then downloads or updates it.
Therefore, because the package-lock.json file locks the version number, when you execute npm install, node will not automatically update the modules in the package.json file, you must use npm install [email protected] (specifyversion number) will be updated after installation, and the version number in the package-lock.json file will also be updated accordingly.
The role of package-lock.json
If you need to use npm install to reload all dependencies when re-npm install and when the node_modules folder does not exist or is deleted, the download address and related dependencies can be directly indicated through package-lock.json, no needThen analyze the dependencies of the package one by one from package.json, so it will greatly speed up the installation. The purpose of package-lock.json is to ensure that all library packages are exactly the same as what you installed last time.
If you want to upgrade the library package in package-lock.json
npminstall [email protected]
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
猜你喜欢
【The 6th Strong Net Cup CTF-Wp】
js cool dashboard plugin
Drools(8): WorkBench uses
php - the first of three solid foundations
MyCat2 introduction and installation and basic use
汉源高科千兆12光12电管理型工业以太网交换机 12千兆光12千兆电口宽温环网交换机
Swiper系列之轮播图
Manual architecture, Mysql interview 126 questions
#Summer Challenge#[FFH] OpenHarmony Device Development Foundation (3) Compilation Dependencies
Thymeleaf
随机推荐
SQL中字符串拼接
FreeRTOS中名称规范
numpy&pands 中的unique
LeetCode_139_word split
MD5 detailed explanation (check file integrity)
DTG-SSOD: The latest semi-supervised detection framework, Dense Teacher (with paper download)
Drools(8): WorkBench uses
js true 3d histogram plugin
Data Lake (2): What is Hudi
unique in numpy & pandas
Thymeleaf
Basic operations of openGauss database (super detailed)
网络流详解(流网图一般能够反映什么信息)
Good shooting js game source code
手撸架构,网络 面试36问
SQL Server database generation and execution of SQL scripts
FreeRTOS实验--一个函数创建多个任务
php字符串的截取方式
Interpretation of new features | MySQL 8.0 GIPK invisible primary key
Swiper系列之轮播图