Skip to main content

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.

yarn-workspaces
Filter by
Sorted by
Tagged with
57 votes
4 answers
22k views

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 ...
33Fraise33's user avatar
49 votes
2 answers
48k views

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 /...
devshorts's user avatar
  • 8,782
49 votes
3 answers
61k views

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 ...
dagda1's user avatar
  • 28.3k
34 votes
2 answers
34k views

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/**", "**/...
Thijs Koerselman's user avatar
30 votes
5 answers
25k views

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 ...
Jeanluca Scaljeri's user avatar
25 votes
1 answer
17k views

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 ...
Andrew's user avatar
  • 295
23 votes
2 answers
16k views

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 ...
J V's user avatar
  • 733
23 votes
1 answer
4k views

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 ...
Xun Yang's user avatar
  • 4,289
23 votes
0 answers
3k views

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 ...
Tom's user avatar
  • 8,028
22 votes
2 answers
3k views

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 ...
Algirdyz's user avatar
  • 617
19 votes
4 answers
23k views

yarn: cannot find module

I have a yarn workspace set up with folders public and server. I am using TypeScript in VS Code. On any module that doesn't have types pre-installed with the package, I get the error in VS Code: ...
tscpp's user avatar
  • 1,475
19 votes
2 answers
4k views

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 ...
axelyung's user avatar
  • 463
19 votes
1 answer
14k views

Using different versions of a dependency in different packages of a Yarn Workspace

I'm relatively new to using Yarn Workspaces and having a Monorepo set up, so forgive me if this has been answered. I don't believe I've found a clear answer on whether or not this is possible for a ...
Sherman Hui's user avatar
19 votes
4 answers
6k views

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 ...
Thiago Nascimento's user avatar
18 votes
3 answers
15k views

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 | | |--...
customcommander's user avatar
17 votes
5 answers
38k views

Error: @vitejs/plugin-vue requires vue (>=3.2.13) or @vue/compiler-sfc to be present in the dependency tree

I'm working with the berry version of yarn with modules federation and vue3. When I run these commands to create the base of the project: mkdir vue-error yarn set version stable yarn plugin import ...
jics's user avatar
  • 2,105
17 votes
1 answer
15k views

Can I use NPX with yarn?

I have a project that I am using yarn for. I've installed all my packages using yarn, I run yarn dev and so on. Now I'm following a tutorial that requires me to use npx to set up a package. - I'm ...
antonwilhelm's user avatar
  • 7,028
17 votes
2 answers
2k views

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 ...
Tdy's user avatar
  • 953
16 votes
1 answer
4k views

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 ...
Kenneth Truong's user avatar
15 votes
1 answer
19k views

Lerna, yarn, and Typescript: Cannot find module or its corresponding type declarations

I have a lerna + yarn workspaces monorepo, with independent versioning. I'm having trouble importing a package in its sibling. I have two packages, one of which should depend on the other, as ...
James's user avatar
  • 740
15 votes
1 answer
13k views

When using yarn workspaces, how to force a package to be installed in the relative node_modules?

I love yarn workspaces, but more often than not I find myself having to pull out a specific package because of incompatibilities with external tools. The main issue is that I don't have their source ...
Paul Razvan Berg's user avatar
15 votes
1 answer
17k views

How do I add shared dependencies to a monorepo using Yarn workspaces?

I am using Yarn's Workspaces feature to manage a monorepo. Some of the individual workspaces have their own dependencies defined in their own package.json, however I also have some shared dependencies ...
old greg's user avatar
  • 877
15 votes
2 answers
9k views

Yarn 2 workspaces not installing dependencies

I'm testing out setting up yarn 2 workspaces. I think I've done it the way I'm supposed to, but when I run yarn install from the root it doesn't install any modules nor does it create the symplink to ...
LoneWolfPR's user avatar
  • 4,050
15 votes
1 answer
13k views

There appears to be trouble with the npm registry (returned undefined). Retrying

I'm trying to install dependencies in my project but when I run yarn install I get the following error [2/5] 🔍 Resolving packages... info There appears to be trouble with the npm registry (returned ...
Hayk Simonyan's user avatar
15 votes
2 answers
8k views

AWS CodeBuild does not work with Yarn Workspaces

I'm using Yarn Workspaces in my repository and also using AWS CodeBuild to build my packages. When build starts, CodeBuild takes 60 seconds to install all packages and I'd want to avoid this time ...
Pedro Arantes's user avatar
14 votes
6 answers
20k views

"'rootDir' is expected to contain all source files" in monorepo

I'm working on converting a large(ish) monorepo into TypeScript for a client, however, I'm pretty new to TS myself and have run into an error that I can't find an obvious fix for. TS6059: File '[path ...
Alex Foxleigh's user avatar
13 votes
2 answers
7k views

Sharing config variables across projects in a monorepo using yarn workspaces?

Is it possible to share config variables / env variables across subfolders of a monorepo that is set up using yarn workspaces? We've got a monorepo for a project, and several of the subfolders are ...
hmlee's user avatar
  • 877
13 votes
2 answers
4k views

Use yarn workspaces and typescript's project references to reference another package subdirectory

I use yarn workspaces and have the following packages: packages/x-cli packages/x-core I want to be able to import symbols from x-core subdirectories, the same way you would do import map from '...
Julien Fouilhé's user avatar
13 votes
1 answer
2k views

How to have TSLint resolve indirect typing dependencies with Yarn workspaces?

Context Yarn workspaces provide for a convenient way to depend on packages in a mono-repo. When package A depends on package B, the interfaces etc. defined in package B are appropriately resolved in ...
Tom's user avatar
  • 8,028
13 votes
3 answers
18k views

Typescript/yarn workspaces - Referenced project may not disable emit

I'm trying to setup a monorepo project using typescript and yarn workspaces. The project's structure looks like this: /example /packages /lib1 Example is an app that used the packages, for ...
Nicolas SEPTIER's user avatar
12 votes
1 answer
15k views

migrating to yarn 3 + workspaces + nohoist

I'm migrating from yarn 1.xx to yarn 3 and I'm currently having a workspaces definition with nohoist configuration in my package.json: "workspaces": { "packages": [ &...
Ziv Levy's user avatar
  • 1,996
12 votes
3 answers
3k views

Typescript, losing Zod and tRPC types across monorepo projects, types result in any

I am in a bit of a weird situation. For the past 2 weeks I've been trying to debug as to why I am losing types between my projects inside a monorepo. My backend exposes the types that my client uses, ...
Nikola-Milovic's user avatar
12 votes
2 answers
10k views

How to install yarn workspace packages without symlink?

I have a yarn workspaces project which looks something like this: node_modules packages shared test.js package.json client test.js package.json server test.js package....
David Callanan's user avatar
12 votes
1 answer
6k views

Sharing typescript code between two projects in a monorepo with yarn 2 workspaces

I want to set up a project with a client part (react-app), a server part (express) and a shared library (utils) in typescript. I use yarn 2 workspaces and wanted to avoid using larna (if possible). ...
Thomas Dunkel's user avatar
11 votes
1 answer
10k views

"Lerna List" and "Lerna Changed" Returns 0 Packages

Gist I have a monorepo and I am using yarn workspaces and lerna to manage it. I had no issues with it until now. I need to know all the changed packages since the last release. Issue So I run lerna ...
Florian Ludewig's user avatar
11 votes
3 answers
22k views

Export multiple modules from NPM package

I have a rather large project A using Node and Typescript. In project A I have a lot of different modules that I would like to reuse in another project B. Therefore I have built the project A with ...
Jolle's user avatar
  • 1,366
11 votes
3 answers
5k views

From inside a yarn workspace subpackage, run a root-level script

I'm wondering: if your terminal's current working directory is inside a yarn workspace, is there a way to run a yarn script that's defined at the project root without changing the current directory to ...
osdiab's user avatar
  • 2,120
11 votes
2 answers
9k views

How to package only the dist folder in a monorepo

I am using lerna and yarn workspaces in my monorepo. The package structure looks like this: root `--- packages |--- pkg1 | |--- src | | `--- index.ts | `--- dist |...
Naresh's user avatar
  • 25.2k
11 votes
4 answers
5k views

Deploying to Firebase Functions with a monorepo

As per Firebase Functions with Yarn workspaces, I'd like to deploy a monorepo to Firebase using Yarn Workspaces. I can successfully deploy the "web" aspect to Firebase Hosting, which references a ...
Craig Myles's user avatar
  • 5,424
11 votes
1 answer
3k views

Enforcing shared dependencies in a monorepo

We have a monorepo using lerna and yarn workspaces. Multiple teams contribute packages to it and there are some common dependencies where we want to force people to use the same version. What are the ...
adanilev's user avatar
  • 3,268
11 votes
0 answers
3k views

Working with yarn-workspace, specify the package root folder to have a nicer import path

Context I am working with yarn-workspace and typescript. Consider the following project structure : project/ |- package.json |- packages/ | |- common/ | | |- build/ | | | `- src/ | | | |- myFile.d.ts ...
benard-g's user avatar
  • 665
11 votes
0 answers
1k views

yarn workspace deploy into a docker image

I am using yarn workspaces and I have this packages in my package.json: "workspaces": ["packages/*"] I am trying to create a docker image to deploy and I have the following Dockerfile: # production ...
dagda1's user avatar
  • 28.3k
10 votes
1 answer
7k views

How do I update all subfolder package.json in a monorepo to the same version?

I have a repository with a bunch of different front-end React projects, which all have package.json files of their own. I have four requrements: I want to keep all of these projects on the same ...
InspectorDanno's user avatar
10 votes
1 answer
3k views

React Monorepo yarn workspaces + typescript + absolute imports

I'm having issues setting up an React project with yarn workspaces and typescript. My folder structure is: -root -package.json -workspaces -web -common and my package.json file is: { "name":...
Guilherme's user avatar
  • 513
10 votes
0 answers
2k views

Error while loading rule '@typescript-eslint/await-thenable': You have used a rule which requires parserServices to be generated

I know this error is all over the place however I tried adding a tsconfig.json file to the parserServices.project already and that did not work. Basically I have a yarn workspace project and my sub-...
David Choi's user avatar
10 votes
1 answer
2k views

Configuring tsconfig.json and eslint for a monorepo using Yarn workspaces

I'm using a Yarn workspace monorepo structure in a TypeScript React project: packages admin package.json user package.json package.json // Workspace Root. Sets "workspaces": [&...
cbdeveloper's user avatar
  • 30.4k
10 votes
0 answers
1k views

create-react-app + gatsby packages in monorepo won't both run

I'm trying to create a monorepo with these packages: a web app created using create-react-app a gatsby site a library of components etc. that the web app and gatsby app will share (which is my main ...
toranpetto's user avatar
9 votes
2 answers
10k views

Yarn Link All Packages/Workspaces

Yarn's link allows you to register a local package for symlinking into another local package. To use link you cd into the package directory and run yarn link. This works fine on individual packages, ...
Undistraction's user avatar
9 votes
1 answer
4k views

Prioritize build order with yarn workspaces and lerna

I have this big typescript project in a mono-repository using yarn workspaces and lerna with the following architecture: repo ├── API │ └── (GraphQL API) ├── Apps │ └── (Front-end React Apps) ├── ...
Marco Daniel's user avatar
  • 5,715
9 votes
2 answers
12k views

What does a `workspace:` prefix in a package.json 'dependencies' value mean?

Where can I learn more about what is workspace: prefix in version number? For example, in Babel: "dependencies": { "@babel/helper-plugin-utils": "workspace:^7.13.0",...
Anton Dozortsev's user avatar

1
2 3 4 5
11