简体   繁体   English

我如何tar node_modules文件夹并从中获取NodeJS

[英]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.

相关问题 如何快速删除 node_modules 文件夹? - How do I delete node_modules folder quickly? 我是否必须将我创建并想要导入的任何脚本/模块放置在 node_modules 文件夹中? - Do I have to place any scripts/modules I create and want to import within the node_modules folder? 如何从nodejs的node_modules文件夹访问公用文件夹中的包? - how to access package in public folder from node_modules folder in nodejs? nodejs中node_modules中的@type文件夹是什么? - what is @type folder in node_modules in nodejs? 将CI用于Bitbucket存储库-我是否需要在根文件夹中包含node_modules? - Using CI for Bitbucket repository - do I need to have node_modules inside my root folder? 如何从拉取请求中删除 node_modules? - How to remove node_modules from the pull request? 我应该如何从node_modules文件夹之外有效地需要模块? - How should I require modules effectively from outside of node_modules folder? 我是否需要Live Server上的“node_modules”文件夹 - Do I Need “node_modules” Folder on Live Server 如何将 node_modules 文件夹添加到现有的角度文件中? - How do I add node_modules folder to existing angular files? 如何在Windows的node_modules .bin文件夹中建立到命令的有效符号链接? - How do I make a working symlink to a command in my node_modules .bin folder on Windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM