简体   繁体   English

节点模块大小?

[英]Node modules size?

I really can't understand what really happens when i run this command in my terminal npm install , after few seconds i find node_modules folder with a size of at least 150MB or far bigger sometimes.我真的无法理解当我在终端npm install运行此命令时到底发生了什么,几秒钟后我发现 node_modules 文件夹的大小有时至少为 150MB 或更大。

This is too much for my network capacity, When i download a movie for example, this doesn't happen in that speed, so i need to understand what is really happening when i run this command.这对于我的网络容量来说太大了,例如,当我下载电影时,这不会以这种速度发生,因此我需要了解运行此命令时实际发生的情况。

Do i really download a 150MB or more files size, or npm just download small files and do some work that makes it that big!我真的下载了 150MB 或更大的文件大小,还是 npm 只是下载小文件并做一些使它变大的工作!

As I understand it, it downloads all that data fully, no post-processing.据我了解,它会完全下载所有数据,无需后期处理。 It does however link the dependencies, so the final size might be a bit larger.然而它确实链接了依赖关系,所以最终的大小可能会大一点。

If you've run npm install previously (even in another folder/directory), subsequent npm install runs can get some/many/all packages from a local cache.如果您之前运行过npm install (即使在另一个文件夹/目录中),后续的npm install运行可以从本地缓存中获取一些/许多/所有包。 From https://docs.npmjs.com/cli-commands/cache.html :https://docs.npmjs.com/cli-commands/cache.html

npm stores cache data in an opaque directory within the configured cache, named _cacache. npm 将缓存数据存储在配置的缓存中的一个不透明目录中,名为 _cacache。 This directory is a cacache-based content-addressable cache that stores all http request data as well as other package-related data.该目录是一个基于缓存的内容可寻址缓存,用于存储所有 http 请求数据以及其他与包相关的数据。 This directory is primarily accessed through pacote, the library responsible for all package fetching as of npm@5.该目录主要通过 pacote 访问,该库负责从 npm@5 开始获取所有包。

If you want to force npm to go over the network so you can compare performance, remove your node_modules directory, run npm cache clear , and then do npm install .如果您想强制npm通过网络来比较性能,请删除node_modules目录,运行npm cache clear ,然后执行npm install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM