Questions tagged [nrwl]
Nrwl - Company behind Nx development. Nrwl provides consulting in the frontend space, helping enterprise teams scale their development. Use nrw-nx if you want to tag a Nx specific question
nrwl
420
questions
99
votes
25
answers
159k
views
Could not find an NgModule. Use the skip-import option to skip importing in NgModule
I get the error in the subject of this post when I use the CLI to create a new component: ng g c my-component --project=my-project (No component is created)
I've seen other posts with the same error ...
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?
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 ...
51
votes
6
answers
47k
views
how can i run a specific angular spec test file in NX workspace?
is there any way to run an specific angular spec test file in Nx work space?
Recently i moved my Angular 4 cli application into Nx work space. Previously i used fdescribe to achieve this ...
29
votes
2
answers
16k
views
How to use app environment.ts in libs in nrwl/nx workspace?
If I have an Authentication lib, with components, service, ngrx, etc... How I can access the environment of the app implementing Authentication lib? So the Auth service should knows the backend url to ...
27
votes
2
answers
22k
views
eslint rule @nrwl/nx/enforce-module-boundaries fails
Intro
I was very confused with that rule when I recently ported the Ng code base to Nx 12.x. I hope this post helps others who begin migrating from Ng to Nx.
The code base above is a rather small ...
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"...
22
votes
5
answers
17k
views
Nrwl Nx: different version numbers and libs
I want to start an Angular project using Nrwl Nx (multiple apps in one project; https://nrwl.io/nx), but I have two questions:
How can I specify different version numbers to the different apps? ...
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/...
18
votes
8
answers
40k
views
How to find the reason of "Cannot find module" for nrwl modules?
I use nrwl.io in my project.
I created several libs:
ng g lib rest //ok
ng g lib services //ok
ng g lib models //created ok, but "Cannot find module " later on!
All of these libs were successfully ...
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 ...
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....
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 ...
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 ...
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 ...
15
votes
1
answer
23k
views
How to globally inject value across modules in NestJS?
I'm working with nx workspace and nestjs.
I would like to inject a value across multiple modules in nestjs app.
Final goal is to reproduce similar way of configuration management as vsavkin mentioned ...
15
votes
2
answers
15k
views
Include a package for some libs in Nrwl/Nx workspace
It seems like in a Nrwl/Nx workspace there is only a single package.json file. Now if we have multiple applications, each dependent on different packages, then we have to include all of those package ...
14
votes
1
answer
7k
views
Why does nrwl nx create a separate e2e project for each app?
When creating a new nx workspace (i.e. with create-nx-workspace) and then generating an app (with ng g app) it creates an app folder inside the apps folder (so far so good) and also another app-e2e ...
14
votes
2
answers
4k
views
How to integrate firebase in Nrwl Nx
I'd really like to integrate firebase as well as firebase cli to my apps in Nx but don't know how. I use firebase functions/hosting/cli-tools, etc. Ideally I'd like to be able to use the firebase ...
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 ...
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 ...
12
votes
1
answer
2k
views
NRWL NX library typescript ambient declaration files
I have a basic setup in my new NX workspace
/apps/my-app (node type)
/libs/some-lib (node type)
Both created with nx cli commands:
i.e. nx g @nrwl/node:lib some-lib --simpleModuleName=true
For ...
12
votes
1
answer
5k
views
peerDependencies configuration for publishable libraries with NX & Angular
I have a monorepo using NX & Angular and I am publishing some libs to NPM and i have the following scenario
apps
only_App
libs
lib_A // v1.0.0
lib_B // v1.0.0
lib_C // v1.0.0
lib_A ...
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 ...
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 ...
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 ...
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 ...
10
votes
5
answers
31k
views
Uncaught SyntaxError: Cannot use 'import.meta' outside a module - Nx Monorepo
I created an angular nx monorepo and created two applications. When I start either of them I get the following error:
I already saw some stackoverflow posts were the answers suggested to just add &...
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 ...
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 ...
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 ?
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 ...
9
votes
3
answers
8k
views
Use jest "watch mode" with nx test (nx CLI)
I have an app that was generated with Nx CLI. I can run tests for this app with Jest using the the command nx test myApp. This works fine. However, I would like to use Jest's "watch mode". ...
8
votes
1
answer
20k
views
prettier vs. nx format:check
nx format:check expects no colon after else in html files:
<div *ngIf="isValid; else errors">
but when I run prettier in the same project it expects a colon after else
<div *ngIf=&...
8
votes
1
answer
18k
views
How to import a component from a library (in nrwl/nx with Angular)
I would like to import my PageNotFoundComponent from my ui-components library into the router of my app.
When I import the UiComponentsModule into my AppModule and use the components in my template, ...
8
votes
4
answers
7k
views
NX: How to create a NX workspace in an existing empty git repository instead of creating it under a workspace name?
I have an existing repository. I have cleared all the unwanted files as I wanted to start a new NX-integrated project. But, I want to continue using the same repository as there are some files which I ...
8
votes
2
answers
1k
views
How to integrate NativeScript into @nrwl/nx
How to share code between multiple NativeScript apps and multiple Angular apps using @nrwl/nx (Nx Workspace)?
7
votes
4
answers
4k
views
nrwl/nx Workspace-Specific Schematics
I've been investigating the nrwl extensions and they look great. However, when I'm following their tutorial for Workspace Specific Schematics, the last step doesn't show me the command to run. Can you ...
7
votes
2
answers
5k
views
Angular 6 - Specify path for lazy loaded chunks
I have a main module with submodules, originally I wanted to make that modules eager loaded, so what I did:
1st Attempt - Eager loading
import {DashboardModule} from './module/dashboard/dashboard....
7
votes
2
answers
5k
views
NX Error for Relative Imports within the Same Project
I'm getting an error when using TS aliased paths within the same project: Projects should use relative imports to import from other files within the same project
I don't want this behavior. Any idea ...
7
votes
1
answer
4k
views
How to set environment variables in cypress.json file through command line? (Angular CLI - nrwl nx)
I am new to cypress and learning day by day, we are trying to implement e2e tests using cypress in angular project.
I am facing issues when I want to set env variables in cypress.json file through ...
7
votes
2
answers
9k
views
Jest test succeed with error printed to console
I'm trying to use jest with an Angular project created by @nrwl/nx. I have followed this article to convert my app from using karma to jest.
The issue I'm getting is that even though my tests are ...
7
votes
0
answers
2k
views
how can i use absolute paths in same library in NX monorepo
I am working on Nx monorepo. We have 5 library and are using imports like this '../../components/Button' in library. but instead of this, we want to use absolute imports.
For example:
there are 2 ...
7
votes
0
answers
2k
views
How to configure dynamic aliased paths in Nx?
Background:
I am building an Angular dashboard where I import widgets (Angular modules and components) dynamically (without routing). I achieved this with the help from this great article https://...
6
votes
4
answers
13k
views
How do you generate services etc. for a @nrwl/nx angular-cli app?
Normally when using @angular/cli to develop an application, you add a new service in the following manner:
ng generate service foo
This would generate "FooService".
My question is, when you have ...
6
votes
1
answer
20k
views
How to replace jest.spyOn().and.returnValue()?
While upgrading Angular (via Nx/NRWL) from 11 to 12, tests started to fail due to: Property 'and' does not exist on type 'SpyInstance<{ afterClosed: () => Observable<{ snoozeDate: Moment; ...
6
votes
2
answers
11k
views
Is there a better way to build an Angular monorepo app with libraries?
I have several apps in my Angular monorepo project. Also there are about 5 libraries I've written to use across the apps.
What I want to know is how to better build/architect these libraries.
The ...
6
votes
3
answers
10k
views
NX @nrwl/node generator error "Cannot find module 'nx/src/utils/code-frames"
I am attempting to generate a new node project using @nrwl/node and when I use the generator I am met with the error
NX Cannot find module 'nx/src/utils/code-frames'
inhibiting me from running the ...
6
votes
1
answer
3k
views
Nx no longer supports the v2 format of angular.json
I am trying to upgrade angular (v15) and nx (v16) in my project, but the issue that I am running into is when I start my project NX throws an error:
> NX angular.json format is incorrect
Nx ...
6
votes
0
answers
284
views
Is there a way to use Nrwl Nx's AST utils for Angular in Nx >13
I wrote a few generators that were working until I did a recent migration. I was importing and using Nrwl AST utils using import paths like:
import { addImportToModule } from '@nrwl/angular/src/utils/...