Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
34 votes
5 answers
17k views

Sharing a typescript library in a monorepo

I'm trying to setup a monorepo with 3 services sharing some library code. This is the current situation: repo: web pdf/ package.json reference to shared-ts using github url tsconfig.json ...
Corentin S.'s user avatar
  • 5,920
29 votes
1 answer
8k views

Can I exclude directories from GitHub Dependabot?

I have a directory /experiments in my repo which contains - surprise! - experiments. Those usually come with their own package.json which includes dependencies that were up to date at the time I made ...
Fred's user avatar
  • 1,604
29 votes
1 answer
15k views

Peer Dependencies In A Monorepo

When packages in a monorepo have peer dependencies, how should these dependencies be made available to them during development? For example a package at /packages/namespace/alpha/ might have a ...
Undistraction's user avatar
24 votes
2 answers
4k views

Install package from lerna-managed monorepo via git URL

I am using yarn for my project. My project has a dependency which happened to be a subpackage of larger monorepo maintained by lerna. The subpackage was updated but not published yet and I need that ...
Max Komarychev's user avatar
17 votes
1 answer
10k views

NPM 8 workspaces - Install one package as the dependency for another package in monorepo

Say I have the following structure packages - @my-scope/packageA - @my-scope/packageB - @my-scope/packageC Let's say I want to install packageA as a dependency of packageB. With NPM 8 ...
Andrew's user avatar
  • 191
15 votes
4 answers
13k views

How do I load a package from a package in a Lerna monorepo?

I have: packages -models -package.json -.... -server -src -index.ts -package.json In my packages/server/package.json, I have: "scripts": { "dev": "ts-node src/index.ts" },...
Shamoon's user avatar
  • 42.8k
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
2 answers
3k views

Using Peer Dependencies With Local (file:../some-lib) Dependencies

I have a monorepo that has many micro-services in it. There are some library-type functions / classes that I want to make available to any micro-service that needs it. However, if that library package ...
Jeremy Thomerson's user avatar
12 votes
1 answer
1k views

How can i Deploy a single npm workspace which depends on packages and other workspaces?

I created a project using npm workspaces and Typescript Project References pretty much exactly like this example repo: https://github.com/Quramy/npm-ts-workspaces-example. This setup keeps all ...
Jeremias Nater's user avatar
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
1 answer
6k views

How can I get live-reload on a local npm package in a monorepo?

I'm setting up a monorepo workspace for a Vue 3 (vite + ts), cloud functions, & shared-lib (shared functions and ts interfaces etc.). I can get the import of my local shared-lib folder to work. I ...
CVE's user avatar
  • 161
11 votes
0 answers
3k views

How to generate per-package package-lock.json for existing Lerna mono-repo

We have an existing Lerna mono-repo that has a structure like: / /packages /package1 /package2 /package3 ... We currently use Yarn for our project, and actually only have a top-...
Matthew Herbst's user avatar
10 votes
5 answers
47k views

Npm workspaces - call workspace script from root package

I'm struggling with multiple npm packages in a root git repository with custom dev scripts to handle launch, compile, build and so on. Now I came across npm workspaces and wanted to use this stunning ...
Alex Pab's user avatar
  • 137
10 votes
5 answers
12k views

Lerna always lists all packages ready to publish when running workflow of Github actions

Lerna does not correctly detect packages change during running workflow of Github actions. If I make none packages related changes, commit and runlerna updatedlocally. it tells me No changed packages ...
eded's user avatar
  • 3,918
9 votes
5 answers
12k views

how to delete all node_modules from all packages in npm 7 workspace monorepo

how can I delete all node_modules folders from all packages in an npm 7 workspace? With Lerna we could just execute lerna clean -y but when migrating to native NPM 7+ workspaces, is there some ...
mesqueeb's user avatar
  • 5,998
8 votes
0 answers
2k views

Lerna avoid symlink

I'm using the below command lerna bootstrap --hoist I want lerna to install all dev and prod dependencies of the packages to the main root node_modules. Some packages are dependencies of each other. ...
javauser35's user avatar
  • 1,255
7 votes
1 answer
7k views

How to create a types only package on NPM

I would like to create a package (monorepo or NPM) that export only types so that in my project I can import them as such import type { MyType } from '@acme/types' I have tried the following solution ...
eakl's user avatar
  • 541
7 votes
3 answers
3k views

creating a monorepo without hosting on a package registry and installing via bitbucket

At my organization, we are trying to create a monorepo of react components so they can be used on several sites. We currently have a repo called react-components hosted on bitbucket and we wanted to ...
James Daly's user avatar
  • 1,386
7 votes
2 answers
6k views

Difference between tsconfig.json and tsconfig.build.json

Many guides (e.g. 1, 2) on setting up NPM monorepos for a TypeScript project instruct having two separate files at the root level, tsconfig.json and tsconfig.build.json. What are the differences ...
Michael Moreno's user avatar
7 votes
2 answers
5k views

NPM Workspaces monorepo - share local package's distribution folder as root instead of the entire source files

Using NPM Workspaces, I'm sharing one package (components) with others (webapp1 and webapp2). Something like this: root apps webapp1 webapp2 packages components Everything is ...
Johnny Oshika's user avatar
7 votes
0 answers
3k views

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

Here are some related questions: When using yarn workspaces, how to force a package to be installed in the relative node_modules? NPM 7 Workspaces - Multiple node_modules? Should I have to use no-...
TrumanGao's user avatar
6 votes
2 answers
2k views

What is a correct approach to a javascript monorepo

I'm trying to figure out correct approach for a javascript monorepo. Imagine monorepo containing packages / libraries: root - node_modules - packages + lib-a * node_modules +...
user3056783's user avatar
  • 2,536
6 votes
2 answers
906 views

Pointing the main field in package.json conditionally

I have a Monorepo under Lerna and Yarn Workspaces. The repo has packages which are published to npm and consumed outside the monorepo as well as within the monorepo. While developing in the monorepo ...
Hamid Aghdaee's user avatar
6 votes
1 answer
3k views

How do you publish and install a private npm package to GitHub packages as an organisation?

We have a monorepo with a shared package called "@myorganization/common", that is used by both the app and Google cloud functions. Google cloud functions requires that the package is ...
Xiiryo's user avatar
  • 3,207
6 votes
1 answer
4k views

How to publish yarn workspace with root package.json dependencies?

I'm trying to publish one (yarn) workspace from a monorepo to npm repository, and include root project's dependencies in the published package. The setup is as follows: package.json (contains shared ...
skrat's user avatar
  • 5,552
6 votes
0 answers
2k views

Creating a usable library on npm... with yarn workspaces

I'm looking for feedback on a pattern I coded while tinkering around. Context I'm creating a package for my company, which going to be released publicly. The DX (Developer Experience) is the most ...
y_nk's user avatar
  • 2,234
6 votes
0 answers
1k views

lerna not generating node_module in packages

I have a monorepo with Lerna and typescript with a basic structure - root package.json - packages package-A package.json src package-B package.json ...
AngularDebutant's user avatar
6 votes
1 answer
1k views

Is there any way to avoid symlinking in monorepo built with yarn workspaces and lerna?

Lets say there is a monorepo with package A and B. Package A is dependent on B. Package B is also published in npm registry. So when installing dependencies it does not install the package B from npm ...
tofaelahmed's user avatar
5 votes
6 answers
10k views

NX ERROR - Nx failed to install dependencies

I'm not sure what could be going wrong and the error message is blank whenever I open it. I've searched online for fixes but nothing has helped hence I'm asking here. My version of node is: v16.1.0 My ...
thursdaysboy's user avatar
5 votes
2 answers
4k views

TypeScript: Watch & compile multiple directories at the same time (monorepo)

I've been scouring the web for a solution, but haven't found anything worthwhile. Basically, I'm looking for a tool or some way to initiate TypeScript file Watching/Compiling in multiple directories ...
Fabis's user avatar
  • 2,052
5 votes
1 answer
3k views

How to set up Lerna monorepo with TypeScript

I have a core library with the following in package.json: "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "es2015": "dist/es2015/index.js", "types": "dist/es2015/index.d.ts", "typings": "...
Kai Sellgren's user avatar
  • 29.6k
5 votes
1 answer
2k views

What is the status of npm "isolated mode" for monorepos?

As it currently stands (March 2023), there is not very much information available when you search "npm isolated mode". The initial discussion began in this github PR, which evolved into the ...
Ryan Wheale's user avatar
  • 27.6k
5 votes
1 answer
873 views

Vscode extension code inside npm workspaces monorepo vsce package error

Im writing a vs code extension inside npm workspaces monorepo, when I try to package it using vsce package, I get this error: This extension consists of <files_count> files, out of which <...
Sergei's user avatar
  • 51
5 votes
1 answer
2k views

Prepare standalone directory to deploy package in a monorepo using npm workspaces

I have a monorepo that uses npm workspaces. root/ app/ package.json server/ package.json store/ package.json utils/ package.json The app/package.json file references private non-...
Jacob's user avatar
  • 78.5k
5 votes
1 answer
2k views

Publish NPM package that uses a workspaces as dependencies

so I have a project that I'm working on that is a Monorepo. So I have a packages directory in the root directory that contains all my npm packages. Some of these packages rely on eachother e.g. in a ...
Artrix's user avatar
  • 159
5 votes
1 answer
736 views

npm publish only if changed in angular monorepo

I have an angular monorepo with an "app" and a library, which is published as it's own npm package. This is done automatically on a CI environment. Until now, the library and the app have been ...
Christof's user avatar
  • 3,887
5 votes
0 answers
740 views

How to use two different React versions in a monorepo with Turborepo and avoid conflicts?

I'm creating a monorepo using Turborepo and have two applications in my apps folder: app-x, which uses "react": "17.0.2", and app-y, which uses "react": "18.0.2"...
Nightcrawler's user avatar
  • 1,061
5 votes
0 answers
674 views

lerna publish push to npm, but not updating dependencies

My Monorepo is currently managed by Lerna.js. It all works fine except for the GitHub actions workflow I use to automate the npm publishing. The situation is as follows: I update packages/types-lib, ...
Cod3n0d3's user avatar
  • 253
5 votes
1 answer
479 views

How to shield the internals of a Lerna package, so other packages cannot import them?

I am working with a Lerna monorepo. I often see one package make imports from deep inside another package, for example: import { SomeType } from "@schema/folder/folder/file.ts" This is ...
Michal Kurz's user avatar
  • 1,943
5 votes
0 answers
735 views

how to use a dependency of multiple major versions in npm 7 workspaces

I have an NPM 7.0 workspaces monorepo. Several of the sub-packages use different major versions of a dependency. However, it seems like NPM workspaces is only able to install a single version and has ...
mesqueeb's user avatar
  • 5,998
4 votes
1 answer
16k views

I'm getting a weird (ERRCODE 243) error when installing a 3rd party js package using Rush.js by running `rush add --package <package>`

my team is migrating to rush and I had a problem while setting it up: I'm getting a weird error when trying to add any 3rd party lib (let's say react) to package.json using rush add --package react (...
ikusteu's user avatar
  • 131
4 votes
1 answer
7k views

How to use yarn add/npm install with monorepos

I need to download a node package from a private monorepo in GitHub, similar to this: monorepoProject --- subProjectA --- subProjectB And both subProjectA and subProjectB are typescript projects, ...
Marcos Paulo Júnior's user avatar
4 votes
1 answer
6k views

PNPM monorepo deployment with docker compose

I currently have a monorepo which has the following structure: . ├── services/ │ └── api/ │ ├── src/ │ │ └── ... │ └── Dockerfile ├── apps/ │ └── frontend ├── packages/ │ └── ...
Sebastiaan's user avatar
4 votes
1 answer
3k views

NPM 7 Workspaces - Multiple node_modules?

I'm having trouble running my app with NPM 7 Workspaces. I am expecting an npm install from the root folder to create a node_modules folder for each of my workspaces, similar to Lerna. However, when I ...
ailish's user avatar
  • 91
4 votes
0 answers
393 views

How can I prevent forbidden dependencies in a monorepo based on npm workspaces and typescript project references?

I am trying to establish module boundaries on compile level in typescript/npm based monorepos but cannot find a way to achieve it. How can I prevent arbitrary imports violating module boundaries? I ...
tscz's user avatar
  • 133
4 votes
0 answers
701 views

How do I target a subdirectory of a (Lerna) monorepo when targeting installation of an NPM package by branch?

Sometimes, it's useful to target a git branch (as in Depend on a branch or tag using a git URL in a package.json? ), with e.g.: "dependencies": { "@my-company-internal-scope/some-...
merkworku's user avatar
4 votes
2 answers
957 views

How can I run two dev servers with yarn workspaces?

I have two yarn workspaces A and B. Within each workspace, I can run yarn start to run webpack dev server on different ports. Therefore, I am trying to use the command yarn workspaces run start to ...
dardub's user avatar
  • 3,186
4 votes
2 answers
793 views

Share tools in root package.json with all packages

I'm building a monorepo using Lerna and npm. It has a typical structure of a root package.json and more packages in subdirectory packages/*. Each package has a script called build that depends on ...
Jonatan's user avatar
  • 3,932
4 votes
0 answers
84 views

Depend on workspace package from a branch in a package.json?

Let's say in my package.json I depend on a next branch by declaring in my dependencies: react-admin": "marmelab/react-admin#next" That repository has workspaces (local packages so to say). For ...
Christiaan Westerbeek's user avatar
3 votes
1 answer
5k views

Vite creating its own node_modules in workspace instead of using monorepo

I have a monorepo for a fullstack webapp with the following directory structure . ├── client │ ├── index.html │ ├── package.json │ ├── src │ └── vite.config.ts ├── node_modules ├── package-...
Michael Moreno's user avatar