Yarn: Feature Request: Centralised node_modules folder

Created on 29 Nov 2016  ·  4Comments  ·  Source: yarnpkg/yarn

Is there a way to install all npm dependencies globally (centrally) so that you do not store node_modules in the project folder?

This is causing problems as the framework the company I work for uses is quite heavy and I have over 40 projects each with their own node_modules folder, packed with millions of 1kb files.

This takes up a surprising amount of precious space on my SSD and it would be really nice if I could just install these packages once, with any project's package.json linking to my local repository

cat-feature help wanted needs-discussion

Most helpful comment

https://github.com/rstacruz/pnpm does exactly this. Uses --preserve-symlinks Node feature.

All 4 comments

@alshdavid things that you require are dependencies, and need to be installed locally. global modules are for non-project-specific command line tools.

imo this isn't really a yarn question unless yarn provides a way to symlink global modules into the local directory, which I'm led to understand wouldn't work with the npm ecosystem.

I think this would be useful. The issue is that it's hard to change how things are done without changing Node.js, as Node.js expects things to be done a particular way and modules to be arranged in a particular way. 😞 I'd also love to rename the directory from node_modules to something else as not everyone uses Node.js.

There's a few GitHub issues around symlinks and hardlinks as a potential solution for performance and disk space - #499 covers hardlinks. The files would still take up some space in the file system though. I feel like a Copy-on-Write filesystem such as BTRFS or ZFS would help with this too, as the files won't actually be copied and would instead just point to the original files in the cache directory.

https://github.com/rstacruz/pnpm does exactly this. Uses --preserve-symlinks Node feature.

The closest to this seems like #499 so I'm closing this one in favor of that.

Was this page helpful?
0 / 5 - 0 ratings