How to install a list of many global packages with Yarn
How am I supposed to indicate that I want a bunch of packages (from package.json / yarn.lock files) to be installed globally?
You shouldn't. Installing globally is discouraged by Yarn, and there are very few situations where it's necessary, or even helpful.
As noted in the documentation:
For the vast majority of packages it is considered a bad practice to have global dependencies because they are implicit. It is much better to add all of your dependencies locally so that they are explicit and anyone else using your project gets the same set of dependencies.
If you are trying to use a CLI tool that has a bin you can access these in your ./node_modules/.bin directory.
But I really, really want to!
If you really don't want to listen to the advice given, use
yarn global add <package>
However, don't expect to easily install a huge list of dependencies globally—it's hard to do by design, because it's not a good idea.
Instead, the intended flow with Yarn is:
- install everything locally, so each project is isolated
- call binaries from
./node_modules/.bin
where possible - avoid global installs—they're a convenience, but not one you should rely on.
Simply type
yarn global add nodejs