I have the classic Lerna set up. root directory, packages folder, 2 subdirectories
I want to just run yarn install
inside one package and just to install the dependencies for this package. for some reason when I run it (even from inside this folder) it's then installing node_modules
inside the root, packageA and packageB.
is there a solution to just allow me to install node_modules
for a chosen directory?
Every yarn package must have a package.json file which yarn looks for in order to identify the package. This file configures the behavior of yarn while it is running inside that package.
Configuring your package Every yarn package must have a package.json file which yarn looks for in order to identify the package. This file configures the behavior of yarn while it is running inside that package. Let us consider a project named scam-register, this package will have a package.json file located at scam-register/package.json:
The package.json file is kind of a manifest for your project. It can do a lot of things, completely unrelated. It's a central repository of configuration for tools, for example. It's also where npm and yarn store the names and versions for all the installed packages. It's empty!
The equivalent of $ npm install is just $ yarn (without arguments) to install all dependencies from package.json. Just found that it has only package.json, which means I can only use npm install to install dependencies. Would there be no problem when I use yarn later? Doesn't matter whether you use yarn or npm, there will always be a package.json.
Check out 'focused workspaces' https://classic.yarnpkg.com/blog/2018/05/18/focused-workspaces/
From inside the package you want to work on, run
yarn install --focus
and Yarn will install the local dependencies as well as any dependencies in monorepo-sibling dependencies, but not all dependencies across all packages in the monorepo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With