-
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
Allow child packages to install into a single node_modules in the root package #711
Comments
One idea we had was to hardlink packages rather than copying them into |
Yeah, that'd be a big improvement already. When you work with a lot of different projects, disk space is more limiting on a Macbook than RAM is (all those VMs... pfft). |
I like this idea, this is something I'd also find useful.
Heh, when testing the various Yarn packages for our public release this morning, I had Debian, Ubuntu, CentOS, Windows 7 and Windows 10 VMs running concurrently... Basically every common OS except Mac OS since I don't have a Mac. Luckily I have lots of RAM on my home PC 😛 |
I'm not sure if this helps in your use case, but have you tried using local packages? The root
Note: Using Then the
And the
Now if you run |
@Pauan, it's so simple yet so ingenious. |
It'd probably be better to push this off into Lerna unless we decide to merge Lerna into Yarn which has been brought up before |
We have the same setup as @StephanBijzitter and are using This is our top level MODULES=$(pwd)/node_modules
PACKAGES=$(find . -name package.json -not -path '*/node_modules/*' -mindepth 2)
for project in $PACKAGES; do
(
cd $(dirname $project)
echo ==== $(pwd) ====
yarn --modules-folder $MODULES
)
done This sort of works, but is highly unsafe. In case of conflicts, a later package will overwrite the dependencies in What we would really like is an ability to hoist dependencies to the highest For example, the following three submodules have different dependencies on
While the |
@guncha Have you tried the solution that I mentioned in this issue? |
@Pauan I did and it would work perfectly if Yarn would symlink the
The dependency hoisting does work as expected, so that's a 👍 |
@guncha Issue 1 is tracked in #499 and #1761 (and possibly #1334 as well). Keep in mind that a lot of people don't want the implicit sharing, because it means that if you change a library, it will affect every single Node.js package on your computer, including unrelated applications and libraries. That isn't a problem with npm or Yarn's current behavior. If you want to modify a package, I recommend using local dependencies, rather than npm dependencies. I just tried your specific example with There are a few solutions:
After choosing one of the above solutions, you should get the desired sharing: I don't see any bug reports for issue 2, maybe you could make a new bug report? As a workaround, does running |
Where i work, we use the same project structure, with local modules, that themselves can have local modules etc. We too faced the problem of unnecessary duplicate dependency installs (which made the install bigger and slower) To solve this, i created a postinstall script, that installs all the dependencies of local modules and submodules etc into the root-node_modules, except when conflicting dependencies are found, those are installed into the associated moudle-node_modules. When looking for options to speed up installation time even more, i came across this issue. I tested my script with yarn, and although my script internally uses npm, running The package ist called minstall. If you are interested in how exactly this script installs the modules, you can look here |
We are addressing this issue in yarnpkg/rfcs#60 |
Implemented in workspaces |
…deployment (based on yarnpkg/yarn#711)
Do you want to request a feature or report a bug?
I want to request a feature.
yarn install
currently does the same asnpm install
, it installs the package in the current working directory. That's good, totally expected.We have a repository that contains one root package, which contains a lot of developer dependencies (like Jest, ESLint, etc). Inside this repository, we have a
modules
directory which in turn has a new subdirectory for each package. As such, it could be visualised like this:Currently, with npm, we parse the
modules
subdirectories for package.json files andcd
to each of them to perform annpm install
. In this example above, we would have threenode_modules
directories. A lot of these modules (a and b), share dependencies, even with the same version ranges. These are currently installed multiple times, which is unwanted.We would like to be able to install these three package.json files into a single
node_modules
directory in the root of the project. This means if module-a and module-b both require jQuery, we would only need to install it once instead of twice (or twenty times...).This should be a command line option, something like:
yarn install --packages=package.json,modules/*/package.json
.It would parse all matching package.json files and create one big dependency tree, and then install this dependency tree into one
node_modules
directory that is at least accessible by the top-level package.json.This would also allow a single lock file to be used, instead of (in this example), 3.
Please mention your node.js, yarn and operating system version.
Node 6.5.0, Yarn 0.15.1, Ubuntu 14.04 (VM)
The text was updated successfully, but these errors were encountered: