当前位置:网站首页>NPM install version number ^
NPM install version number ^
2021-02-23 17:47:05 【SuShine】
npm
The dependent version number in is ^x.y.z
, Which versions can be included ?
Today, a colleague has a problem , One of the things we rely on in our code npm
package , It's a version of hard-source-webpack-plugin@^0.12.0
, But in execution npm install
When , The installation is always 0.12.0
This version , Not the latest version of this package 0.13.1
.
At first , I thought it was because of lock
Why , Such as the package-lock.json
perhaps yarn.lock
, I know someone lock In the document , Locked version for 0.12.0
. But the reality is , Because the code of my former colleagues is a little bit bug, Although the source code does have package-lock.json
and yarn.lock
Of documents , But the actual release time , Because of the code bug, These two files were not published to npm
In the warehouse .
The current situation is ,package.json
The version written in is ^0.12.0
, This bag is in npm
The latest version of the source is 0.13.1
. But by npm Install it , Always be 0.12.0 Of , Not at all 0.13.1.
According to the previous understanding , The semantic version is ^0.12.0
, So it can cover [major, minor, patch] The three digit version of The last two Of , It should be installed automatically 0.13.1 This version .
Is it the pot of cache ? Um. , There may be ,npm There is indeed a local cache . So clear the local cache npm cache clean —force
, reinstall ,WFT? still 0.12.0 ah !!
It doesn't look like the pot of caching . Is that a network problem ? Neither , Even if you clear the cache, you can still install it to 0.12.0 , The Internet must be OK Of ……
Looks like , Objective cause It's almost done …… Only from Subjectively We got a problem .
Version number ^0.12.0
, It really includes 0.13.1
Well ??
Turn it over again npm Version official document have a look , Um. , I was wrong before . The document makes it clear that ,^
Specified version range , as long as No modify [major, minor, patch] In triples , The first one on the far left is not 0 position , It's all right . in other words , To be sure ^
The scope of the version , First find The first one on the far left is not 0 position , Only the change on the right side of this one , Is included in this ^
Within the specified range . Take up a :
^1.2.3
The version includes :>=1.2.3
also <2.0.0
^0.2.3
The version includes :>=0.2.3
also <0.3.0
^0.0.3
The version includes :>=0.0.3
also <0.0.4
meanwhile , I also found one on the official website npm
Command line tools :semver
, Can be installed globally :npm i -g semver
, after , You can use this tool to check what a range version contains , Take today's problems , That's it :
bogon:~ jess$ semver -r ^0.12.0 0.12.0 0.13.0 0.13.1
0.12.0
bogon:~ jess$
bogon:~ jess$ semver -r ^0.12.0 0.12.0 0.12.1 0.12.10 0.13.0 0.13.1
0.12.0
0.12.1
0.12.10
bogon:~ jess$
bogon:~ jess$
PS :
We are currently in the application code , To prevent some packages from being upgraded , Not following the semantic version , This leads us to apply after every package , The generated code may be different , Generally used yarn.lock
perhaps package-lock.json
To lock the version number of the package the project depends on .
But last time there were students in the open source Third party package in , It turns out that most of them are No, yarn.lock
perhaps package-lock.json
, It's a little strange , Why are these open source packages , Don't lock the dependent third-party version ?
I understand it , It's about these two aspects :
- All say
nodejs
Ofnode_modules
It's a hole deeper than a black hole , It can be seen that in one of our applications , How many third-party open source packages will you rely on . Every open source package , It depends on a lot of other packages . If every open source package locks its own dependent version , So many of the underlying infrastructure packages , It may be installed many , Although justpatch
There are some version differences , After the front-end code is packaged , The volume will undoubtedly increase a lot . therefore , Open source package for and other open source packages share The lower package , You can't lock your own version - In fact, the first point has already explained the problem , As the author of open source packages , Maybe there's no other choice , Can only choose Believe in Other open source package authors , Will strictly abide by Semantic version The requirements of
The related documents
版权声明
本文为[SuShine]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/02/20210223174446187t.html
边栏推荐
- A small intelligent robot: help us automatically pull people, automatically verify payment, automatically transfer payment to personal bank card
- [4 / 25] enable template method pattern in page objects
- [5 / 25] chain of responsibility pattern
- 在Visual Studio中创建一个新的ASP.NET项目
- PAT_甲级_1108 Finding Average
- Create a new one in Visual Studio ASP.NET project
- PAT_ Grade A_ 1108 Finding Average
- NTP时间同步服务器(时钟服务器)如何助力桥梁监控系统的?
- How does NTP time synchronization server (clock server) help the development of bridge monitoring system?
- 正则表达式:备忘录
猜你喜欢
-
Regular expressions: memos
-
FIL将为新一代币王
-
Fil will be a new token King
-
PAT_甲级_1109 Group Photo
-
PAT_ Grade A_ 1109 Group Photo
-
location.host和location.hostname区别
-
大专文凭,干过工地;奋斗了六年成为阿里资深架构师,现年薪百万!
-
location.host and location.hostname difference
-
College diploma, worked in construction site; worked hard for six years to become a senior architect of Ali, with a salary of one million!
-
【亲测有效】Win10家庭版Microsoft Edge页面出现乱码的两种解决方案及gpedit.msc命令无法使用的解决策略
随机推荐
- Two solutions and solutions of garbled code on Microsoft edge page of win10 Home Edition gpedit.msc Solutions to the problem that commands cannot be used
- PAT_甲级_1110 Complete Binary Tree
- PAT_ Grade A_ 1110 Complete Binary Tree
- 实际工作中到底如何开展性能测试????
- How to carry out performance test in actual work????
- UNI-APP 记录
- Uni-app record
- PostgreSQL
- PostgreSQL
- 【STM32F407】第5章 RL-USB移植(MDK AC6)
- 单机最快MQ—Disruptor
- PAT_甲级_1111 Online Map
- [stm32f407] Chapter 5 rl-usb porting (MDK AC6)
- Single fastest MQ - disruptor
- PAT_ Grade A_ 1111 Online Map
- 如何避免微服务设计中的耦合问题
- How to avoid coupling problem in microservice design
- 51信用卡股价年初至今上浮5倍,引入银行背景高管担任行政总裁
- 51 the share price of credit card has risen five times since the beginning of the year, and senior executives with bank background have been introduced as the chief executive
- prometheus监控之进程监控(process-exporter)
- 华为轮值董事长胡厚崑:技术创新的同时要避免社会发展的分化
- 疫情推动“宅经济”,企业防御DDoS更加不能松懈
- 二分图最小点覆盖构造方案+König定理证明
- Anno&Viper -分布式锁服务端怎么实现
- 解决Win7 X64由于百联控件造成的蓝屏问题 (PassGuard_X64.sys)
- Process exporter of Prometheus monitoring
- 浅谈 Vite 2.0 原理,依赖预编译,插件机制是如何兼容 Rollup 的?
- Hu houkun, Huawei's rotating Chairman: avoid the differentiation of social development while making technological innovation
- The epidemic situation promotes "residential economy", and enterprises' defense against DDoS cannot be relaxed
- Construction scheme of minimum point cover of bipartite graph + proof of K ü nig theorem
- npm install 版本号^的坑
- Activity显示界面背后的故事:一文让你理清View的那些复杂关系
- Android面试官:Window连环十二问你顶得住吗?(快扶我起来,我还能问)
- 开发一个小程序,最好先做好课前工作
- SQL Server中DELETE和TRUNCATE的区别
- Simar 的 参考书
- 【招聘】分布式存储架构师 40K-80K*14薪
- How to implement anno & Viper - distributed lock server
- Solve the blue screen problem of win7 x64 caused by Bailian control (PassGuard)_ X64.sys)
- Talk about the vite 2.0 principle, dependence precompile, how is plug-in mechanism compatible with rollup?