简体   繁体   中英

pnpm - Do node_modules directories occupy the same space in disk?

I have multiple Vue.js projects spread across my laptop's file system. I have searched and found a solution to the npm node_modules folder size problem with pnpm. After installing the projects dependencies with pnpm i , the size of the node_modules folder still says that it occupies 233 MB of space in each project. I was simply wondering if all of these project's node_modules folders are using the same 233 MB of hard disk space assuming that all projects have the same dependencies.

Yes, all of those project's node_modules use the same 233 MB of disk space.

From the FAQ page of pnpm website :

Why does my node_modules folder use disk space if packages are stored in a global store?

pnpm creates hard links from the global store to project's node_modules folders. Hard links point to the same place on the disk where the original files are. So, for example, if you have foo in your project as a dependency and it occupies 1MB of space, then it will look like it occupies 1MB of space in the project's node_modules folder and the same amount of space in the global store. However, that 1MB is the same space on the disk addressed from two different locations. So in total foo occupies 1MB, not 2MB.

For more on this subject:

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