Questions tagged [yarn-workspaces]

Yarn Workspaces is a feature that allows users to install dependencies from multiple package.json files in subfolders of a single root package.json file.

Workspaces are a new way to setup your package architecture that’s available by default starting from Yarn 1.0. It allows you to setup multiple packages in such a way that you only need to run yarn install once to install all of them in a single pass.

Documentation

509 questions
52
votes
4 answers

How to build a docker image from a nodejs project in a monorepo with yarn workspaces

We are currently looking into CI/CD with our team for our website. We recently also adapted to a monorepo structure as this keeps our dependencies and overview a lot easier. Currently testing etc is ready for the CI but I'm now onto the deployment.…
33Fraise33
  • 641
  • 1
  • 6
  • 6
47
votes
2 answers

How to use yarn workspaces with typescript and out folders?

I'm trying to set up a monorepo using yarn. I'm confused as to how to set up typescript with project references such that things resolve properly. For example, if I have a folder structure like /cmd /client And I want cmd to depend on client I…
devshorts
  • 8,572
  • 4
  • 50
  • 73
45
votes
3 answers

why does yarn warn when adding a dependency to the root workspaces package.json

Whenever I add a dependency to the root of the workspaces project: e.g. yarn add assets-webpack-plugin -D I get the following error: Running this command will add the dependency to the workspace root rather than the workspace itself, which might…
dagda1
  • 26,856
  • 59
  • 237
  • 450
30
votes
2 answers

How to target a single workspace with Yarn?

I have workspaces set up like this "private": true, "workspaces": { "packages": [ "packages/*" ], "nohoist": [ "**/firebase-admin", "**/firebase-admin/**", "**/firebase-functions", …
Thijs Koerselman
  • 21,680
  • 22
  • 74
  • 108
27
votes
4 answers

nohoist with workspaces still hoisting

Inside my Monorepo I have one packages in which I want all the dependencies inside its node_modules. But whatever I do, it's node_modules remains empty. So, for the purpose of my question I was able to reproduce the issue with the following…
Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333
23
votes
1 answer

Yarn workspace, react, monorepo issue with conflict library version

I'm experimenting with yarn workspace monorepo. It is consisting of a TestProject created with create-react-app, and a SharedLib1 which is created with create-react-library. TestProject imports code from SharedLib1. The problem being, TestProject…
Xun Yang
  • 4,209
  • 8
  • 39
  • 68
22
votes
2 answers

How to deploy one app from a large monorepo with dependencies to packages in the same repo to google app engine?

I have a large node.js monorepo with several applications and packages and inter dependencies. It is all managed with yarn workspaces and a little bit of lerna. Everything works great for me, however I am having trouble trying to deploy one of the…
22
votes
0 answers

With Yarn workspaces, how can compiled binaries be linked to the workspace post-compilation?

Context Yarn workspaces provide for a convenient mono-repo-like functionality where packages are automatically linked. I.e. they can require/import each other, and their binaries are linked and accessible from the workspace root. An…
Tom
  • 8,536
  • 31
  • 133
  • 232
21
votes
2 answers

Monorepo with paths from Typescript is not working

I have monorepo (yarn workpaces) with following file structure: ├── client (workspace @client) │   ├── package.json │   └── tsconfig.json (extended tsconfig) ├── server (workspace @server) │   ├── getData.ts │   ├──…
J V
  • 703
  • 2
  • 7
  • 12
21
votes
1 answer

Within a yarn workspace, how can I force a resolution for a child project's dependency?

I'm using a library that has supports another library with a wide range of versions as a peer dependency. Unfortunately, one of the child projects of the workspace pulls in a version different from the child project that uses the library. As a…
Andrew
  • 255
  • 1
  • 2
  • 7
19
votes
4 answers

Firebase Functions with Yarn workspaces

We're starting to adopt a monorepo setup using yarn workspaces and we'd like to have our firebase functions inside it. The repo structure is something like: repo node_modules <- all dependencies packages core commom …
19
votes
2 answers

Are there any advantages to using Lerna with Yarn workspaces?

We're in the process of migrating our monorepo to use Lerna. Lerna supports both NPM and Yarn and furthermore allows configuration of use with Yarn workspaces. It's unclear to me whether Lerna with Yarn workspaces has any distinct advantages to…
axelyung
  • 463
  • 4
  • 9
16
votes
1 answer

How do I keep yarn workspaces dependencies in sync

Let's say I have multiple packages in my yarn workspaces. @mycompany/utils @mycompany/app @mycompany/serv Let's say each of these packages has a dependency on lodash. I want to make sure that they all have the same lodash version. Is there a way…
Kenneth Truong
  • 3,882
  • 3
  • 28
  • 47
15
votes
2 answers

How to handle node_modules with docker-compose in a monorepo project

I'm running a Node.js monorepo project using yarn workspaces. File structure looks like this: workspace_root node_modules package.json apps appA node_modules package.json appB …
Tdy
  • 863
  • 12
  • 28
15
votes
2 answers

Why does Yarn throw "Invariant Violation: expected workspace package to exist" when I attempt to upgrade some dependencies?

I have a monorepo that is managed by lerna which relies on the Yarn workspaces feature. It looks like this: /repo |-- packages | |-- pkg-a | | |-- package.json | |-- pkg-b | | |-- package.json | |-- pkg-c | | |--…
customcommander
  • 17,580
  • 5
  • 58
  • 84
1
2 3
33 34