简体   繁体   中英

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. 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.

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. It could also be one file per dependency in package.json.

See Node's issue #1278 on GitHub - Compressed packages:

and npm's issue #49 on GitHub - Add option to store dependencies compressed:

I'v been thinking about similar for our docker builds and am looking at Yarn and using the Yarn Offline Mirror . It should get you your 1 file per dep. You'll probably also want to turn on automatic pruning .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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