[英]How do I tar the node_modules folder and have NodeJS pull from that
One project that I worked on recently had a grand total of 15000 files, and as we all know, those are usually small files. 我最近从事的一个项目总共有15000个文件,众所周知,这些文件通常都是小文件。 Thousands of files can be a headache for everyone, and I am wondering if there is a way to tarball the node_modules folder and tell nodejs to pull all dependencies from that folder.
成千上万个文件可能让每个人都感到头疼,我想知道是否有办法压缩node_modules文件夹并告诉nodejs从该文件夹中提取所有依赖项。
My understanding is that a module should never write to its own folder as it may not have the required permissions, so I would think this would work. 我的理解是,模块永远不应写入其自己的文件夹,因为它可能没有所需的权限,因此我认为这会起作用。
It doesn't have to be tarball, just something that gets everything in less than ten files. 它不必是tarball,只需将所有内容存储在少于10个文件中即可。 It could also be one file per dependency in package.json.
它也可以是package.json中每个依赖项一个文件。
See Node's issue #1278 on GitHub - Compressed packages: 在GitHub上查看Node的问题#1278-压缩包:
and npm's issue #49 on GitHub - Add option to store dependencies compressed: 和GitHub上npm的问题#49-添加选项以存储压缩的依赖项:
I'v been thinking about similar for our docker builds and am looking at Yarn and using the Yarn Offline Mirror . 我一直在为我们的docker构建考虑类似的问题,并且正在研究Yarn并使用Yarn Offline Mirror 。 It should get you your 1 file per dep.
它应为您每单位1个文件。 You'll probably also want to turn on automatic pruning .
您可能还需要打开自动修剪功能 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.