So I am using Angular with NX and I have the following groups books
and cars
. For both groups I want to create an overview
lib with a table to view the books or cars.
So I create the lib under libs/books/overview
next up I want to do the same for cars libs/cars/overview
. But then I run into this issue:
Error: Project name already exists.
Do I need to name the libs like books-overview
? Then I would create the following lib: libs/books/books-overview
. books
is redundant so it doesn't seem like the best option.
The folder name does not have to be same as the app. Instead, you could create parent folder for each dash separated part of your library name.
You can create lib with name 'books-overview'
in folder books/overview
.
Running the command with the folder structure as name, it correctly decides on the name. Running
npx ng generate @nrwl/workspace:library --name=books/overview
will generate library 'books-overview'
in folder books/overview
.
For example this is config of our application (we also use nx):
// angular.json excerpt
"api-java-model": {
"projectType": "library",
"root": "libs/api/java/model",
...
},
"api-java-client": {
"projectType": "library",
"root": "libs/api/java/client",
...
That way you don't have a folder collision.