Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

NPM and using symlinks instead of full copy to local modules. #12515

Closed
tomitrescak opened this issue Apr 28, 2016 · 5 comments
Closed

NPM and using symlinks instead of full copy to local modules. #12515

tomitrescak opened this issue Apr 28, 2016 · 5 comments

Comments

@tomitrescak
Copy link

Hi, this may be a silly question which I tried to find answers to online but I failed, so I'm asking here. NPM always copies all files to local modules when doing npm install .... This is a nightmare for moving files around, backups, size (SSD drives). For example, I have several Javascript/Webpack projects (around 20-30) which share 99% of modules. Each project has around 700MB - 1GB due to te size of node modules dir (1-2MB w/o node_modules) making it easy 30GB of files out of which are 99.5% the same.

My questions is: Is it possible to setup NPM so that it would use symlinks from local repository to project modules instead of tediously copying everything into every new project?

I know that one way of doing this is via global modules and npm linking ... this is not good obviously as it would fail in CI. Meteor package service (Atmosphere) is doing this and it really saves a lot of space/instalation time.

@kenany
Copy link
Contributor

kenany commented Apr 28, 2016

linklocal :)

@tomitrescak
Copy link
Author

@kenany looks nice, but this only solves the local modules. I'm talking about having ALL modules as symlinks (e.g. React). Is that doable?

@tomitrescak
Copy link
Author

Hm, this is quite bad that there is no solution. It is also a big issue for cloud backups. I am just setting up a new computer with fresh cloud backup and my 34 javascript projects contain 2.7 million!!!! files. When I profiled these files by merge program they were 96.4% equal. So, it's basically having same file in 150 different copies across several packages. Will this ever be targeted? Please don't gent me wrong, I love NPM but would you consider this?

@tomitrescak
Copy link
Author

tomitrescak commented Jun 11, 2016

The answer is pnpm project. I wrote a little article about it here

@ghost
Copy link

ghost commented Dec 4, 2016

You might be interested... There's still some problems with using symlinks, but this issue on nodejs/node shows how a few simple tweaks to node would make symlinks and node_modules go together like bread and butter

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants