-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yarn vs npm install node_modules bloat #2673
Comments
For an application that I have here to test with: NPM version: 3.10.3 after
after
I started trying to compare the 2 node_modules folders to see what is different, and it looks like yarn and npm have different ways of determining what to do when multiple versions of a module are needed. It looks like Yarn duplicates more under submodules node_modules, and npm either gets lucky, or determines which module version has more dependencies and puts that version at the root, resulting in less sub-module duplication. In other words, if multiple versions of a module are needed, NPM and Yarn seem to put different versions at the root level, and then submodules that don't use that version at the root level get their own copy under the submodule's node_modules. So conceptually I end up with something like: If modules A, B and C all depend on module X. npm:
Yarn:
so Yarn ends up with more module duplication... I have no idea if this is just a coincidence based on the order that modules are installed, or a product of the algorithm that flattens the modules... someone who knows the Yarn code may be able to investigate further... Just a quick update post-fix for this issue: after
after
👏 |
should be fixed by #2676 |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Yarn is bloating the node_modules directory, 5x file count vs npm and 2.5x file size
If the current behavior is a bug, please provide the steps to reproduce.
Using create-react-app as an example
Folder Example:
node_modules (after npm install, 24 KB)
-> babel-helpers
-> -> lib
-> -> package.json
-> -> README.md
node_modules (after yarn install, 2 MB, everything is the same except sub node_modules)
-> babel-helpers
-> -> lib
-> -> node_modules
-> -> package.json
-> -> README.md
What is the expected behavior?
I wouldn't expect a yarn install to have 5x the files of an NPM install on the same package list.
Please mention your node.js, yarn and operating system version.
node - 7.5.0
yarn - 0.19.1
macOS Sierra Version 10.12.3 (verified also happening on Windows 7)
The text was updated successfully, but these errors were encountered: