All Questions
Tagged with monorepo javascript
186
questions
61
votes
1
answer
30k
views
the difference between nx and Lerna ? (monorepos)
hello i'm in new in monorepos world and i'm now searching about different monorepos tools
and i found two intersting tools Nx(nrwl) and lerna but i didn't understand the real differnce between these ...
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
...
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 ...
26
votes
6
answers
53k
views
Building Typescript: [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
I've encountered problem building typescript packages with rollup inside lerna managed monorepo.
Error:
lerna ERR! rollup --config ../../rollup.config.js stderr:
loaded ../../rollup.config.js with ...
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 ...
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 ...
20
votes
2
answers
16k
views
How Should VSCode Be Configured To Support A Lerna Monorepo?
I have a lerna monorepo containing lots of packages.
I'm trying to achieve the following:
Ensure that VSCode provides the correct import suggestions (based on package names, not on relative paths) ...
18
votes
2
answers
25k
views
Eslint doesn't work in VScode, but work from terminal
I have monorepository managed by rush (https://rushjs.io/)
The structure of code is:
As you see, there are two eslint configs and two directories node_modules (it is just symlink created by rush).
...
17
votes
3
answers
20k
views
what the different between `pnpm install` and `pnpm add`?
I am work on monorepo stuff, and found that some guys use pnpm install to install packages in workspace, but some other use pnpm add.
in the pnpm docs, its seem like the same between add and install ...
15
votes
3
answers
8k
views
How to avoid install of packages in monorepo using Yarn
I built a monorepo using Lerna and Yarn workspaces.
Everything works fine but everytime I install a new dependency on a package (let's call him A) using:
yarn add <package_name>
Yarn adds it ...
14
votes
2
answers
4k
views
Go to Typescript Source Definition instead of Compiled Definition in Visual Studio Code
I am working on a typescript project with Visual Studio Code including multiple npm packages structured like this:
Source code: /src/index.ts
Compiled code: /dist/...
When I right click on imported ...
14
votes
1
answer
4k
views
lerna link vs. lerna bootstrap
I have a Lerna project which until recently was using lerna bootstrap --hoist. This worked well but I found the devDependencies in the many sub folders were mostly identical. Upgrading to Lerna v3 I ...
11
votes
1
answer
6k
views
pnpm in monorepo - how to run a command only in a specific package?
Let's say I want to install a package in a specific package in my monorepo, how do I do this from root?
in npm, you can do this with something like this:
npm install react --workspace=a
I searched ...
11
votes
1
answer
2k
views
Typescript: resolve relative import path when using symlinks
This seems like a dumb question, but I struggle to find the answer.
The situation
Here is my folder structure:
myProject/
├── module1/
│ ├── config.ts
│ └── init.ts #symlink
├── module2/
│ ├── ...
10
votes
1
answer
3k
views
How to Share Build Scripts In Lerna Packages
I have a lerna repo that contains multiple packages organised in the usual structure:
package.json
/packages
- alpha
package.json
- bravo
package.json
- charlie
package.json
I need ...
9
votes
1
answer
4k
views
Lerna / Nx / Turborepo or other monorepo systems for non-js apps (php)
I have repository with /frontend (JS/Vue) and /backend (PHP) and docker-compose.yml for development. But now I need to add another JS frontend that will be sharing some components, libs etc. I do not ...
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, ...
9
votes
3
answers
6k
views
Turborepo Eslint config not applying
I created a Turborepo testing project and I wanted to try if ESlint config that it's set in the root of the Turborepo applies to all of the projects inside my /apps folder, turns out it does not work ...
9
votes
2
answers
3k
views
Monorepo - Multiple .vscode settings
Project structure
I have the following project structure:
/
| - .vscode/
| - - - - settings.json
|
| - packages/
| - - - - app/
| - - - - - - index.js
| - - - - - - package.json
| - - - - website/
| - ...
9
votes
0
answers
785
views
Importing files in subdirectories when using Yarn Workspaces and Typescript
I'm having trouble porting a Yarn Workspaces monorepo to TypeScript. In the previous working version of the monorepo, moduleA could import something from a subdirectory of moduleB.
The new ported code ...
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.
...
7
votes
2
answers
7k
views
How to share Vite config in monorepo?
I am trying to make monorepo using Turborepo. I have a lot of Vue projects there and I need to share Vite config across all applications. Here's how I'm trying to achieve this.
I have package named @...
7
votes
1
answer
5k
views
Jest with tyescript in monorepo doesn't work with dependency out of the root folder
I use Jest with Typescript. I want to create a monorepo.
My folders structure is:
fe
|-app1
|--.jest.config.ts
|--tsconfig.json
|-shared
|--dummyData.ts
I want a unit test from app1 to access some ...
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 ...
7
votes
0
answers
2k
views
Force Hoisting Of Package Dependencies In Yarn (v1) Workspace
I have a monorepo containing many packages. It is using yarn(v1) workspaces. One of the packages contains a set of development dependencies (packages/example-dev/@example/dev) that are consumed as a ...
6
votes
1
answer
6k
views
Expo: Cannot resolve entry file: The `main` field defined in your `package.json` points to a non-existent path
I am working with the default typescript template generated from the command line npx create-expo-app -t expo-template-blank-typescript and I get this error when I try to start the project.
The main ...
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
+...
6
votes
1
answer
4k
views
How Can I Fix VSCode Import Path Suggestions In Lerna Monorepo?
VSCode does a great job with autosuggesting imports, however inside a (Lerna) monorepo it only suggests relative paths from one package to another, for example:
import example from '../../../@scope/...
6
votes
1
answer
2k
views
Folder hierarchy in packages - Turbo/Monorepo
Many articles and tutorials teach how to share components in monorepo projects.
But they show something in an unproductive way.
Share each component (package1, package2) separately in workspace. What ...
6
votes
1
answer
2k
views
Dealing with Docker images in a Javascript/Typescript monorepo with unpublished packages
I've been trying to find a clear answer to this problem, but unfortunately I haven't been able to. There are two similar SO questions that touch on this subject,
Should a developer be able to create a ...
6
votes
0
answers
854
views
Can I publish only a subset of packages in one Turborepo, using Changesets?
As seen in the Turborepo docs, the monorepo can include internal packages in order to share code between apps inside the monorepo.
There is also a docs section on how to publish packages in a monorepo,...
6
votes
0
answers
936
views
How to use local resolutions in yarn workspaces?
I have a monorepo based on yarn workspaces, with two projects, A and B. Both projects depend on the foo package.
I would like to create a resolution in the parent package.json file (since resolutions ...
6
votes
0
answers
496
views
How do I use ES6 imports in Detox tests with Yarn Workspaces?
I have already integrated Detox to my react native project (using yarn workspaces) and it works ok. But when I want to use import syntax the tests fail.
This is the error:
import { linkBarTest } ...
5
votes
2
answers
9k
views
Can Lerna bump prerelease version according to the Conventional Commits specification?
It doesn't seem that Lerna 3.20.2 is able to bump prerelease versions (e.g. 1.0.0-alpha.0) according to the Conventional Commits specification.
I made a Minimal Reproducible Example if you want to ...
5
votes
1
answer
2k
views
VSCode - Turborepo - Automatic import suggestion for local packages misses the main entry point
We recently regrouped several repositories into a single monorepo using turborepo for better code reusability using local packages.
Our folder structure looks like this:
/apps
| /app1
| /app2
/...
5
votes
2
answers
3k
views
Dependencies in Monorepo
In a monorepo, if you have a dependency in one package can you use that dependency in another package without adding it to that package? For more clarity, check the below layout.
Project
|-packages
...
5
votes
1
answer
3k
views
How to use eslint plugin modules located in parent directory?
I have some services organized into a monorepo in such a fashion:
repo_root/
├── services/
│ ├── service_one/
│ ├── service_two/
│ └── service_three/
├── package.json
├── node_modules
├── ....
5
votes
1
answer
1k
views
Nx monorepo: elsint can not resolve paths with @ specified in tsconfig.base.json (import/no-unresolved
I'm working on an NX monorepo project. I have linting configured. I have:
.elsintrc.json
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [
...
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 ...
5
votes
0
answers
2k
views
Next.js multi zones with i18n and shared components
I am using Next.js' multi zone feature with a blog and web app so I can develop and deploy both apps independently. It was easy to set up by following their with zones example and I have set up a blog ...
5
votes
0
answers
241
views
When using a babel.config.js as well as specifying options in webpack babel loader, would it merge both or ignore babel.config.js?
Hypothetically, if someone puts configuration of babel in three files at the same time:
babel.config.js
babel key in package.json
babel loader options/query in webpack.config.js
Then which one of ...
4
votes
1
answer
8k
views
NX monorepo fatal: No such ref: 'main~1'
I'm trying to build my nx application in github actions with nx cloud enabled. I always get the fatal: No such ref: 'main~1' error.
The command nx affected --target=build --base=main~1 --head=HEAD --...
4
votes
1
answer
3k
views
Publishing multiple cobertura coverages with TFS CI
I have a monorepo project, created with lerna. And, I use Karma+Jasmine for the unit testing. The project structure looks as follows:
|-packages
| |-package1
| | |-coverage
| | | |-cobertura
| | | | |-...
4
votes
3
answers
419
views
Passing Firestore (v9) instance across packages
I'm trying to write some Firestore operations into a separate package so that it could be imported and reused in different web apps. I'm building a monorepo with different packages and I'm trying to ...
4
votes
1
answer
2k
views
Monorepo with Expo and Multiple Entry Points
I have two Expo (React Native) apps that share most of their code and are already in production. We are trying to move them to a monorepo directory structure as follows:
lerna.json
package.json
...
4
votes
1
answer
978
views
Lerna Monorepo keeping individual git repos as packages
In lerna, one can initialize git at the root level of the lerna project and inside the packages folder, we keep our small individual projects. Now suppose, you want to keep the git histories and ...
4
votes
0
answers
251
views
Lerna, conventional commits and long term support releases
We have a number of packages in a monorepo, managed by Lerna and with mandatory conventional commits. While everyone's on the same page at the HEAD of master/latest version, things work great. But we ...
3
votes
1
answer
4k
views
Watch for changes in an npm link package being built with webpack
I have the following directory structure:
application
|
|__ component-library
|
|__src
|
|__ app
|
|__src
...
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-...
3
votes
2
answers
6k
views
How to deploy monorepo powered by turborepo to Vercel?
Recently, Turborepo is acquired by Vercel. So I was excited to experiment with that. I created a turbo repo project by running
pnpx create-turbo
Then I tried to deploy it to Vercel following the ...