How to Create Modules Using the CLI
Explore how to create Angular modules using the CLI commands to streamline development. Understand generating modules in specific folders and importing them into the main AppModule for organized scalable application structure.
Create the module in the current folder
So we’ve covered the metadata of the @NgModule decorator, and now it’s time to start creating our own modules. Now that we know the structure of a NgModule class, we could start writing our modules by hand, but thankfully, the Angular CLI team has created a way to generate modules with a few simple commands.
To create a new module using the CLI, we use the generate command. We’ve already used this command to generate new components in our example application. The full command for creating a module is as follows:
ng generate module <modulename>
So if we wanted to create a new module named AdminModule, we would simply use this command:
...