foreword
Hello everyone, my name is Lin Sanxin. uses the most and easy-to-understand words to describe the most difficult knowledge points. is my .
background
I don’t know if you have noticed during development, but there are two files in your project:
package.json
package-lock.json
It should be that many people usually do not pay attention to the relationship between these two files! Let me tell you a little bit today, so that when the interviewer asks next time, everyone can also hold a cup~~
example
background
In package.json
, the version of vue
is ^2.6.14
.
"vue": "^2.6.14",
^
means that if Vue updates the minor version 2.6.15
under the major version 2 in a few days, then when you npm install
, Vue will automatically upgrade to 2.6.15
caused problems
For example, there are programmer A and programmer B two developers
- Programmer A: The version of Vue was
2.6.14
when he took over the project, and he has been using this version - Programmer B: Join this project a month later, at this time Vue has been upgraded to
2.9.14
, and it will be automatically upgraded whennpm install
Summary: This will lead to different versions of Vue when two people are developing, which will lead to some problems and errors in cooperative development.
package-lock.json
package-lock.json
can solve the above problems, his role is: lock the version number of the installation module
For example, there are two developers, , programmer A and programmer B.
- Programmer A: The version of Vue was
2.6.14
when he took over the project, and this version was locked atpackage-lock.json
- Programmer B: Join this project a month later. At this time, Vue has been upgraded to
2.9.14
andnpm install
. It is reasonable to say that it will be automatically upgraded. However, since the versionpackage-lock.json
is locked in2.6.14
, the automatic upgrade is prevented, and the guaranteed version is still2.6.14
Epilogue
I'm Lin Sanxin, an enthusiastic front-end rookie programmer. If you are motivated, like the front-end, and want to learn the front-end, then we can make friends and fish together haha, touch the fish group, add me, please note [Si No]
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。