I have a project using monolithic repositories. Each packages has his own package.json file to manage dependencies for the said package. I'm using lerna
to install package in all "sub-packages" of our monorepo app.
The current project structure looks like this
Project/ | package.json | node_modules/ |- packages/ |-- package1/ |--- package.json |--- node_modules/ |-- package2/ |--- package.json |--- node_modules/
I'm looking into a way of generalize common dependencies in the root node_modules folder so each packages doesn't pull his own copy of a node package when running lerna exec -- npm install
but instead use the one that is at the root of the monolithic repo so we avoid installing the same package in multiple repo, hence, reducing the size of the project.
I've seen some solution including to make some symlinks between project but that's doesn't seems to be an exact science since symlink support is very OS opinionated. Also, this doesn't seems to be a supported way of doing it.
Currently, we're just at the beginning and after running lerna exec -- npm install
the project is already around 350mb on disk and pulling everything from npm takes around 5 minutes the first time. As the project will grow over time, this time will also extend over time...
So to resume everything, I'm looking for a way to extract the common dependencies in a node_modules folder at the root of the repo and make the sub-packages pull from this folder their common dependencies instead of getting their own copies everytime.