In this post, I thought of addressing one of the errors which many of friends have been asking since few days. Actually, angular template under dotnet stack has been changed. For more info around the same, please refer my earlier post http://myview.rahulnivi.net/dotnet-angular-aurelia-knockout-react-redux-vue/. It means developers when used to execute angular template either via dotnet cli command or via yeoman generator, there used to be app.module.ts file. At this moment, when I try creating new component say ng g c movies, this will give below error.
Error locating module for declaration – SilentError: No module files found – While trying to create a new component or service using the angular CLI. This occurs because the angular CLI is expecting to have a file with name app.module.ts and with the new convention; this file splitted into 3 files as
One solution to this problem is either rename app.module.shared.ts to app.module.ts and then create the component, it will work. But the problem with this approach is while creating new component, it won’t automatically gets registered with module file which means every time you add any module or service, you will have to manually register the same in the module file.
The other solution which I usually prefer renaming client file as in app.module.client.ts to app.module.ts. Now, open the renamed file
Here, I have applied …(three dots) for declarations section inside bracket, so that it can refer the appropriate files. Now, we need to fix the reference for this file in boot-client.ts. Below is the updated file.
With the above change in place, let’s say when I create new component via ng g c movies. It will automatically register the same app.module.ts file.
Below is the glimpse of the updated module file.
Therefore, this is the tiny change around new template system. Rest all remain the same. Thanks for joining me.
1,781 total views, 1 views today