Markus
Markus

Reputation: 2274

How can I install ng-bootstrap to an nx mono repository?

When trying to install ng-bootstrap into a multi project mono repo using Nx I get the following error:

npx ng add @ng-bootstrap/ng-bootstrap --project=web-app

The add command requires to be run in an Angular project, but a project definition could not be found.

I am assuming this is because I am using project.json. It is an Angular project but without angular.json.

Upvotes: 0

Views: 3164

Answers (1)

Alain Boudard
Alain Boudard

Reputation: 873

Ok, now as an answer I have this for you :

  • If you installed properly Nx AND an Angular project, you should have this message :
PS D:\tests\nx\demo> ng add @ng-bootstrap/ng-bootstrap --project myapp
Ng add is not natively supported by Nx
Instead, we recommend running `npm install @ng-bootstrap/ng-bootstrap && npx nx g @ng-bootstrap/ng-bootstrap:ng-add`
√ Run this command? (y/N) · true

But of course this will fail because the Nx schematics did not handle the --project parameter (there is a PR to be done I guess !) :

>  NX  Generating @ng-bootstrap/ng-bootstrap:ng-add

✔ Packages installed successfully.
SchematicsException [Error]: Unable to find project 'undefined' in the workspace

So, for your particular case, I'd say you did not choose the Angular option when scaffolding the Nx workspace, or you migrated to project.json ... or you did not run the ng add command from the proper directory.

Upvotes: 2

Related Questions