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 why I want to create the nestjs module as lib is becuase I have got several nestjs applications in my mono repo and as per nrwl nx guidelines if I have to share code, which is module in my case, it has to be a lib.
Can anyone please share the command to do the following thing:-
Any help is much appreciated.
The workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.
I got the command that does the job finally and sharing with other encase they require help
ng generate @nestjs/schematics:library mynestlib
Quote from Nx Workspace official documentation :
Creating a Lib Adding new libs to an Nx Workspace is done by using the Angular CLI generate command, just like adding a new app.
ng generate lib mylib ng generate library mylib # same thing
This will create a new lib, will place it in the libs directory, and will configure the
angular.json
andnx.json
files to support the new lib.Run
ng generate lib --help
to see the list of available options.
ng generate lib mylib --directory=myteam
will create a new application inlibs/myteam/mylib
.
If --directory
is not defined, it will ask you in which directory it should be generated, and what framework should be used (Angular or TS).
If it's not working, please, maybe you should check your Nx version, and also your angular.json
.
@nrwl/schematics
could not be the default collection used as this issue
mentioned.
angular.json
"cli": {
"defaultCollection": "@nrwl/schematics",
"packageManager": "yarn"
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With