To solve this problem, I had to first import ModuleRegistry and AllCommunityModules in maint.ts
and add ModuleRegistry.registerModules(AllCommunityModules); below just before platformBrowserDynamic().bootstrapModule(AppModule) like:
import { ModuleRegistry, AllCommunityModules } from '@ag-grid-community/all-modules';
ModuleRegistry.registerModules(AllCommunityModules);
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
Lastly, in the component (e.g. users.component.ts) I used it by importing the AllCommunityModules and declaring the variable like:
import { AllCommunityModules } from '@ag-grid-community/all-modules';
public modules: Module[] = AllCommunityModules;