Every time npm install package-lock.json changes

problem description

package-lock.json is used to fix the dependent version. Why is it that most of the time the version of npm install package-lock.json, is supposed to be fixed and should not be changed without installing a new dependency? why?

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

package-lock.json does not change

Npm
Sep.07,2021

is also curious about this question, to sum up:

reason: package-lock.json will save the version of all the dependencies (including dependent dependencies), download address, etc. Because of the different requirements of the dependent version in the project package.json, there will be different ways to write it, such as limiting the minimum version, limiting the scope of the version, and so on. So running npm I at different times may result in new versions of some dependencies, resulting in changes in package-lock.json. This can happen even if your project directly depends on a fixed version number, but your dependency cannot be fixed.

workaround: nmp 5.8 or 5.9 added a new command, npm ci to quickly install dependencies completely from package-lock.json, without causing this problem.


take a look at this article, Portal


because you want to update and download the package


npm installation principle:
_20191226132938.png

if there is no conflict between your package.json and your package-lock.json, the package-lock.json file will not be updated, otherwise it will be updated.

Test npm version: 6.13.1

Why does it conflict? For example, you manually changed the version number, such as relying on core-js 3.4.5, as shown in figure

.
-sharp-sharp package.json
"dependencies": {  
  "core-js": "~3.4.5"  
}
-sharp-sharp package-lock.json
"dependencies": {  
  "core-js": {  
    "version": "3.4.7",  
    "resolved": "https://registry.npm.taobao.org/core-js/download/core-js-3.4.7.tgz",  
    "integrity": "sha1-PdplYR2VaZtet3QupFHqBS03qmU="  
  }  
}

depends on core-js ~ 3.4.5 and locks on 3.4.7 .
you change the dependency of core-js in package.json to ~ 3.4.6 , ~ 3.4.7 , reinstallation will not change package-lock.json , because the version saved in lock file is larger than that in package file.

but if you change the version in the package.json file directly to "core-js": "~ 3.4.8" , this is higher than the version in the lock file. If you need to download the latest version again, you will download the latest version that conforms to 3.5.x . Update the lock file at the same time.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4775d-44c3b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4775d-44c3b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?