Skip to main content

Questions tagged [nrwl-nx]

Nx is an open source, next generation build system with first class monorepo support and powerful integrations.

Filter by
Sorted by
Tagged with
95 votes
5 answers
109k views

How to clear Nx cache

I have an Nx monorepo (https://nx.dev). It has a folder with Nx cache (./node_modules/.cache/nx/). Its size for now is over 3GB. Is there a command for clear this cache?
Pax Beach's user avatar
  • 2,599
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 ...
anis's user avatar
  • 875
39 votes
10 answers
30k views

Add Angular Material to Nx Workspace

I'm wanting to add angular-material to my nx-workspace. The angular material docs (https://material.angular.io/guide/getting-started) say I should run ng add @angular/material. I've tried that in the ...
vicatcu's user avatar
  • 5,687
27 votes
6 answers
53k views

'nx' is not recognized as the name of a cmdlet

I am trying to add a new util library into my Nx mono repo. I googled and found the following command from www.nx.dev: nx generate @nrwl/nest:library util/util-myLibName When I run the above command, ...
Mohsen's user avatar
  • 1,030
23 votes
7 answers
18k views

TypeORM OneToMany causes "ReferenceError: Cannot access '<Entity>' before initialization"

I have two entities: User and Habit. A user can create multiple Habits, thus I use a OneToMany relation on the User (and ManyToOne on the Habit, respectively). User Entity import {Entity, ...
Duca Vitalie-Alexandru's user avatar
22 votes
1 answer
9k views

Angular Nx Nrwl - Cannot parse tsconfig.base.json: PropertyNameExpected in JSON when try to create a new lib

Im getting this error Cannot parse tsconfig.base.json: PropertyNameExpected in JSON at position 891 when i run nx g @nrwl\angular:lib libName on CLI my tsconfig.base.json { "compileOnSave"...
Luis Fernando's user avatar
22 votes
2 answers
20k views

NX workspace, how to change an Angular app name with the the cli?

I have NX workspace with some apps and the product decided to change one of the apps name, how can I do it without manually change the app's folders names, modules names, all the importing paths, NX ...
Elad's user avatar
  • 2,277
22 votes
7 answers
16k views

Global Type Declarations within a NX and NextJS monorepo

I've been looking around the web to try and find s nice solution to my problem but so far I have not. I have a NX monorepo with NextJS and I am trying to create a global types/ folder that can be used ...
lukehillonline's user avatar
21 votes
2 answers
18k views

How can I get the previous commit before a push or merge in GitHub Action workflow?

I'm using Nx for monorepo support on a new project. One of the benefits of Nx is that it can determine which apps in the monorepo are affected by a range of changes (start commit, end commit). So if ...
Rich McCluskey's user avatar
20 votes
3 answers
26k views

Generate package.json on nx build / deployment

I've a monorepo using nx with multiple node/nestjs apps. Some of the apps doesn't require all the packages used in the other apps. Because it's a monorepo, I need to install all packages for every ...
N0Cloud's user avatar
  • 231
20 votes
3 answers
12k views

Error: Cannot find module '@nx/nx-linux-x64-gnu'

I'm trying to run the build of my Angular project using NX in the CI with GitHub Actions, but it fails with errors such as: npm ERR! code 1 npm ERR! path /runner/_work/myapp/node_modules/nx npm ERR! ...
Francesco Borzi's user avatar
19 votes
7 answers
25k views

NRWL NX importing lib error TS2307: Cannot find module '@eduboard/interfaces'

I've just created a new NX project for work and I've created a lib for out interfaces to have them on the backend and the front end. I'm getting this error when I compile apps/askeddi/src/app/pages/...
Skel's user avatar
  • 1,658
17 votes
8 answers
27k views

Nx CLI run many command is not working for multiple apps

I have tried using Nx in an attempt to make use of Monorepos. I have been facing an issue to serve multiple apps via nx run-many command. Can anyone correct me if I'm doing something wrong? Command ...
Chan15's user avatar
  • 999
17 votes
6 answers
17k views

process.env.NODE_ENV always 'development' when building nestjs app with nrwl nx

My NX application's npm run build:server calls ng build api-server that triggers the @nrwl/node:build builder. It builds the NestJS application as main.js. Things work except I wanted process.env....
kctang's user avatar
  • 11.1k
17 votes
1 answer
20k views

Module Federation Shared Services

I'm working on a new project using Angular 11 and Webpack 5. I am basing my work on Manfred Steyer's Module Federation Plugin Example repo, which uses Angular CLI. I can't figure out how to share a ...
Mike's user avatar
  • 1,286
17 votes
1 answer
14k views

Managing shared styles and assets in Ngrx-nx Monorepo

I am trying to set up shared styles and assets (i.e. fonts) in a nrwl-nx monorepo for use in libraries and apps. My desired outcome is having a library 'theme' that provides shared styles scss ...
derdaani's user avatar
  • 578
17 votes
1 answer
5k views

Is it possible to use different apps as git submodules in a nx workspace?

I want to build a nestjs backend which is used by a angular frontend application. Each of them for now in a single repository. I stumbled over nrwl-nx for monorepo tooling and am really intrigued to ...
Hüftl's user avatar
  • 231
17 votes
0 answers
4k views

How to pass arguments to eslint when using nx lint

I want to use eslint arguments such as --no-error-on-unmatched-pattern. https://eslint.org/docs/user-guide/command-line-interface#options However, when using nx lint/nx run-many --all --target=lint/nx ...
Adam Marshall's user avatar
16 votes
6 answers
22k views

ReferenceError: React is not defined - Migrating from CRA to Vite and NX

I'm currently in the process of migrating a create-react-app (CRA - v4) monorepo Webpack setup to an NX Monorepo powered by Vite. I'm currently stuck trying to figure out how to solve the typical ...
Jose A's user avatar
  • 10.8k
16 votes
3 answers
19k views

update an nx-angular project to a specific major version of angular

I am a bit lost in the versioning system of nx (with angular). In my case, I want to upgrade from angular 12 to angular 13 with latest compatible tooling (jest, nx). Agnular 14 is out now. So if I run ...
yonexbat's user avatar
  • 2,982
16 votes
1 answer
11k views

Difference between `nx affected:lint --fix` and `nx format:write`

What is the difference between nx affected:lint --fix and nx format:write? Different articles does seem to mention that code should be formatted with nx format:write command, but it doesn't seem that ...
InsFi's user avatar
  • 1,318
16 votes
1 answer
7k views

Providing typescript declaration file for external lib with Nx

This question has been asked and answered many different ways on Stack overflow and I think I've tried them all. This question is specific to getting it to work using @nrwl/nx. The specific error is ...
Jeff's user avatar
  • 959
15 votes
4 answers
6k views

How to enable Swagger for API interfaces shared between NestJS and Angular within Nx monorepo?

I would like to enable Swagger for API interfaces, shared between NestJS and Angular app within an Nx monorepo. Is there a consistent and not workaround-looking way? These are the approaches I haven'...
Andriy Chuma's user avatar
14 votes
3 answers
13k views

Is it possible to rename libs to packages in nx?

I want to rename libs folder that nx creates to packages. Is it something possible with nx?
Jon Sud's user avatar
  • 11.3k
13 votes
2 answers
5k views

My project doesn't compile with optimization parameters after upgrading from angular 11 to angular 12

I just upgraded an environment with nrwl from angular version 11 to 12 with two angular applications and several libraries. After update when I try to compile using optimization settings: angular.json ...
Conde's user avatar
  • 877
13 votes
4 answers
14k views

Jest "Cannot find module" with typescript paths in CI

On the Gitlab-CI environment 2 of our Jest tests fail with Cannot find module. The strange thing is that it works on my local Win10 machine - even when I run the tests in a similar docker-container (...
TmTron's user avatar
  • 18.6k
13 votes
8 answers
13k views

Building library with imports from another library using NX Monorepo

Here is the case. I am using Nrwl NX Monorepo. I have 2 libraries: lib-a and lib-b; both are publishable libraries created via NX. Now I create a MyClass.ts in lib-a. Naturally under paths in ...
Hivaga's user avatar
  • 4,296
13 votes
2 answers
4k views

Use .feature files in cypress with nrwl nx

I have an Angular project with an Nrwl Nx workspace. For my e2e test I use cypress with typescript. For this tests I would like to enable support for Feature files with Gherkin Syntax. I added the "...
Alexander Wissmann's user avatar
12 votes
1 answer
12k views

Is there any way to set default port for nx react apps

I create multiple apps using nx monorepo, but when I try to run nx run-many to start all apps at once, but I got the error that the port is already taken, which is true. when I run apps one at a time, ...
Kousher Alam's user avatar
  • 1,035
12 votes
2 answers
49k views

Why am i getting error on using any `nx` commands

Command used : nx internal/modules/cjs/loader.js:983 throw err; ^ Error: Cannot find module '@nrwl/workspace/src/command-line/supported-nx-commands' Require stack: - /Users/shawntony/projects/...
Vinz and Tonz's user avatar
12 votes
4 answers
5k views

NX - UI Library with Storybook and individually exported components

I'm exploring Nx with Angular (relatively new to both) and trying to figure out how to generate a component library that: Can run Storybook, and Can be imported one component at a time, rather than ...
Sasha's user avatar
  • 6,396
12 votes
2 answers
14k views

@nrwl/nx angular Run all test for coverage in a single test run to get all covered code in my mono repo

I'm running tests in multiple projects of my nx angular monorepo and would like to get a single code coverage report of all projects with all code files covert from the tests. The test-runs seems to ...
Richard Liebmann's user avatar
11 votes
3 answers
16k views

How to use short paths for importing in Nx Workspace?

I have created an NX Workspace using Angular preset. Where I have one app and two libraries. Inside my app, I am trying to use shorter paths for import. With my current approach inside my app, I can ...
RAHUL KUNDU's user avatar
11 votes
2 answers
4k views

What are the differences between a @nrwl/js library and a @nrwl/workspace library?

I have created both in a testing environment but am still having trouble to differentiate between the use cases of the two. They both have the same file structure, slightly different tsconfig.json ...
fmi21's user avatar
  • 545
11 votes
2 answers
10k views

Nrwl Nx build for production missing node modules bundle

I have a Nrwl Nx repo with different apps (angular, nodejs with express) and shared libs inside. The repo was created with the nx cli and I want to build for production one of the express apps. nx ...
Rares P's user avatar
  • 313
11 votes
1 answer
12k views

How to build and package only the relevant dependencies using nx?

I have a project using nx that has many packages in it. My problem is that I only have a single package.json file so if I want to build only one package I still have to build the root project using ...
Adam Arold's user avatar
  • 30.1k
10 votes
2 answers
7k views

VSCode needs to be restarted after modifying tsconfig and tslint files in nrwl nx projects to eliminate errors

I'm working on a project with Nrwl nx in VSCode and whenever I change a route to a library or the prefix for a library my code shows a bunch of false errors. Everything still renders as expected but ...
Optiq's user avatar
  • 3,086
10 votes
2 answers
8k views

NX: Copy one extra file to build directory

I have a project that I've built with nx and I'm deploying it to Google App Engine. It needs app.yaml in the same folder. Is there a way to tell nx builder to copy that extra file to the build ...
Konstantin Bodnia's user avatar
10 votes
4 answers
9k views

Nrwl nx command to generate lib for nest module

I am new to nrwl nx cli and extensively searched through their documentation and could not find the command to generate the nestjs module as lib rather than the actual module within app. The reason ...
Atul Chaudhary's user avatar
10 votes
1 answer
3k views

Lint rule "no-restricted-imports" throw error when patterns group specified

I configured .eslintrc.json in Nx/nrwl monorepo for React project. When I add group to pattern attribute to no-restricted-import "rules": { "no-restricted-imports": [ &...
Vaibhav's user avatar
  • 1,462
10 votes
1 answer
5k views

Error running Jest in nx monorepo: SyntaxError: Unexpected token 'export'

Background I have a monorepo project built using Nx. This repo contains several reusable libraries for my backend projects. The packages is collected from several projects to create a reusable library....
Fahmi Noor Fiqri's user avatar
10 votes
2 answers
4k views

Gitlab CI/CD and Nx affected:build

I'm having trouble getting Nx to build properly inside Gitlab's CI/CD tool. > nx affected:build "--prod" "--base=remotes/origin/development~1" "--head=remotes/origin/development" fatal: Not a ...
davehyperion's user avatar
10 votes
1 answer
3k views

How to collect code coverage from playwright to Sonar (Angular Project)

seeking help regarding the topic. There is an Angular project built with nrwl that includes Playwright e2e tests. However, I am unable to extend the existing unit tests (which are Jest based and were ...
Serje Strelov's user avatar
10 votes
1 answer
3k views

Is there a way to clear NX Cloud cache?

I know I can clear nx cache with nx reset but is there a way to clear the NX Cloud cache? I could not find a command or an option in their GUI that would enable this.
Felipe Plets's user avatar
  • 7,460
9 votes
3 answers
8k views

Since Jest 25, coverage reports are having a different source path

I'm running an Angular project with an @nrwl/nx setup and Jest for unit tests. I have configured Jest to generate lcov files for each app and lib, which are then picked up by SonarQube Scanner to ...
PaNic175's user avatar
  • 350
9 votes
5 answers
32k views

How to host NextJS app on 0.0.0.0:3000 with nrwl/next (not localhost:3000)

I'm trying to host my app on 0.0.0.0:3000 and not localhost. However each time I run the nx serve career --port=3000 --host=0.0.0.0 The app is hosted on: tcp6 0 0 :::3000 :::...
Salman's user avatar
  • 1,005
9 votes
4 answers
5k views

Why nrwl/nx is better that angular@6 vanilia?

Biggest advantage og nrwl/nx was implementing multiple workspaces in one project. Now angular 6 supperts it as well. What are other adventages of nx over angular@6 ?
piernik's user avatar
  • 3,647
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 ...
norr's user avatar
  • 2,042
9 votes
5 answers
24k views

Project extension with invalid name found in Angular with NX

I am using Angular with nx and when I try to nx serve todos I get this error: Project extension with invalid name found And my project name is: todos. I followed this https://nx.dev/angular-tutorial/...
Alireza Ahmadi's user avatar
9 votes
2 answers
13k views

Nx React inject environment variables at runtime

I have a Nx monorepo with multiple react applications. I want to be able to run the build once and then deploy the same build to multiple environments (e.g. dev, test, production). What I used to do ...
marinvirdol's user avatar
  • 1,463

1
2 3 4 5
18