npm 缓存_npm缓存:无名英雄

npm 缓存

by Siddharth Kshetrapal

通过Siddharth Kshetrapal

npm缓存:无名英雄 (npm cache: the unsung hero)

I love npm and believe that this package manager is the single biggest reason for JavaScript’s massive success these past few years.

我喜欢npm,并且相信这个包管理器是最近几年JavaScript取得巨大成功的唯一最大原因。

There was a lot of excitement in the JavaScript community when facebook released yarn. And for good reason. Yarn’s install speeds are amazing. Subsequent installs are even faster because yarn caches installed modules on your machine.

当Facebook发布yarn时,JavaScript社区引起了很多兴奋。 并且有充分的理由。 纱线的安装速度惊人。 后续安装甚至更快,因为yarn会在您的机器上缓存已安装的模块。

But there’s an npm feature that does not get nearly the attention it deserves.

但是有一个npm功能并没有获得应有的关注。

Like Yarn, npm also has a built-in caching mechanism that can make subsequent installs super fast.

与Yarn一样,npm也具有内置的缓存机制,可以使后续安装变得非常快。

Here are some benchmarks:

以下是一些基准:

That’s crazy, right? And guess what: this feature has been available to you this whole time, but it’s disabled by default.

太疯狂了吧? 猜猜是什么:此功能一直可供您使用,但默认情况下处于禁用状态。

如何启用npm缓存 (How to enable npm cache)

npm config set cache-min 9999999

That’s it.

而已。

Now install your packages as usual:

现在照常安装软件包:

npm install express

You can try out these benchmarks for yourself using this repository:

您可以使用以下存储库自己尝试这些基准测试:

siddharthkp/npm-cache-benchmarknpm-cache-benchmark - Benchmark npm cache vs yarngithub.com

siddharthkp / npm-cache-benchmark npm-cache-benchmark-基准npm缓存与yarn github.com

Note that Yarn is not just about speed — it has other features like consistent installs, which set it apart.

请注意,Yarn不仅涉及速度,还具有其他功能,例如一致的安装,这使其与众不同。

But, if speed is an important consideration for you — as it sure is for me — you should give npm another try, this time with cache.

但是,如果速度对您来说是一个重要的考虑因素(对我来说肯定是对的),则应该再次尝试npm,这次是使用缓存。

Thanks to ashley williams for reviewing this and to npm, for being awesome.

感谢ashley williams对此进行的评论以及npm的出色表现

P.S. You should totally follow me on twitter.

PS:您应该完全在Twitter上关注我

翻译自: https://www.freecodecamp.org/news/npm-cache-the-unsung-hero-11e646c09791/

npm 缓存

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值