Error message during ng Build Prod: Component declared in two modules when it should be in the same module

When running the ng build --prod command, I encountered an error message that is causing some confusion:

The error states: Type SiteSecurity in "PATH"/siteSecurity.component.ts belongs to the declarations of 2 modules: SiteSecurityModule in "PATH"/siteSecurity.module.ts and SiteSecurityModule in "PATH"/siteSecurity.Module.ts!

This issue seems to indicate that my component is declared by two different modules, even though they are supposed to be the same.

Here is a snippet of the code involved:

siteSecurity.routing.ts

import { ModuleWithProviders } from '@angular/core';
import { RouterModule } from '@angular/router';
import { SiteSecurity } from './siteSecurity.component';
import { AuthGuard } from '../../../../../ReusableServices/AuthGuard';

export const SiteSecurityRouting: ModuleWithProviders = RouterModule.forChild([
    {path: 'Datahub/Admin/Auth/SiteSecurity', component: SiteSecurity, canActivate: [AuthGuard]}
]);

siteSecurity.module.ts

import { NgModule }           from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { SharedModule } from '../../../../../ReusableComponents/SharedModule';
import { SiteSecurity } from './siteSecurity.component';
import { SiteSecurityRouting } from './SiteSecurity.routing';
import { SiteSecurityService } from './siteSecurity.service';

@NgModule({
    imports: [BrowserModule, SiteSecurityRouting, SharedModule, FormsModule],
    declarations: [SiteSecurity],
    providers: [SiteSecurityService]
})
export class SiteSecurityModule {
}

It appears that SiteSecurityModule is only imported into a parent module without any other references or imports elsewhere.

I suspect that the dual declaration of SiteSecurity in both the routing file and module file might be causing this conflict. However, removing it from either location results in errors. Has anyone encountered a similar problem before? What could be causing this issue?

My @angular/cli version is 6.2.4

Answer №1

It is important to remember that import paths are case sensitive, so the uppercase M in an import statement could be causing the problem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for evaluating the stickiness of a block within a cell when it adheres to a mat-header-cell

I am working with an Angular table and facing an issue. How can I make the span element in the cells of the first column stick to the sticky mat-header-row when scrolling down the table? My requirement is for the span element to stay attached to the lower ...

Encountered an issue when attempting to include a model in sequelize-typescript

I've been attempting to incorporate a model using sequelize-typescript: type AppMetaDataAttributes = { id: string; name: string; version: string; createdAt: string; updatedAt: string; }; type AppMetaDataCreationAttributes = Optional<App ...

Error in Angular Template Parsing Due to Dynamic Object Key in Angular Version Greater Than 2

When I attempt to assign a value for a key with a variable inside my event binding expression, an unexpected error occurs: Parser Error: Unexpected token [, expected identifier, keyword, or string at column... the expression in question is: (ngModelChange ...

Is there a way to fetch a particular object from Firebase database based on its value using AngularFire2?

Here is the database I am working with: firebase database I am trying to retrieve a dish that has its 'featured' attribute set to true (dish.feature = true). Is it possible to do this directly from the database, or do I have to retrieve all di ...

The error `npm run server` is not able to recognize the command '.' as an internal or external command

While working on my project from github https://github.com/angular-university/reactive-angular-course, I encountered an issue. Even though I have all the latest dependencies and am running on Windows, I am facing this problem. Interestingly, it works fin ...

Angular is throwing an error with code TS2322 stating that a number cannot be assigned to a string type

While trying to convert a PHP variable gender from string to number, I ran into the following error: Error TS2322: Type 'number' is not assignable to type 'string' in Angular Here's the code snippet: param = { id: '&ap ...

Omit assets in final version

During development (ng serve), I have specific assets like images and styles that I use. These assets are not needed in the production build as they are provided by a CDN. My requirements are: When using ng serve, I want to serve files from the folder . ...

Demonstrate JSON data using ngFor loop in Angular

Need some assistance here. Trying to display data from a .json file using a ngFor loop. However, I keep running into the following error in my code: Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgF ...

The functionality to close a Mat dialog is not functioning properly on Angular 11 with Material 11

I am trying to close the dialog by calling the close function of MatDialogRef instance, but unfortunately it is not working as expected. Within my ShareModule, there are components like HeaderCompose and LoginComponent. The HeaderComponent utilizes the Lo ...

After routing, parameters are mistakenly being inserted into the URL

When working with Angular 5 and using routing to move between pages / components, I am facing an issue. Specifically, in the login component, after signing out I navigate to the Home component but unnecessary parameters are being added to the URL. Below i ...

Encountering an error with "unexpected token import" while utilizing localize-router in an Angular 4

I am currently working on building an Angular 4 app with server-side rendering and language-specific route paths. I am using Angular CLI version 1.5.0-rc1 for this project. While everything seems to be functioning fine, I am facing a problem with incorpor ...

An error was encountered when attempting to define a file that contains both a class and an interface with an expected sem

Seeking guidance on creating a Typescript file with a class and interface: export class Merchant { constructor( public id: string, public name: string, public state_raw: string, public users: string, ) {} }; export interface MerchantL ...

Encountering an error with loading %5Bobject%20Object%5D on a webpack-generated JavaScript file hosted in an express server because of Stylus styles

I have been experimenting with enhancing the example linked here. Initially, everything worked smoothly when I used npm start. However, I wanted to integrate it into an existing ExpressJS project. To achieve this quickly, I copied the three js files to the ...

Unusual problem with [(ngModel)] not updating after Apollo subscription

I've encountered a strange issue with [(ngModel)] while working on an Angular 5 project. I have set up a form with inputs that successfully connect to the database using Apollo for sending GraphQL queries and mutations. The issue arises in editing set ...

Tips on managing both the ionic 3 and ionic 4 versions cohesively on my device

Currently, I am utilizing multiple apps with ionic 3 version and everything is working smoothly. However, for my upcoming project, I am interested in using ionic 4 without uninstalling ionic 3. When attempting to install ionic 4 locally using the command b ...

The TypeError occurs when attempting to access the 'modelReplicationStartDate' property of an undefined entity

Encountering an issue while running Angular unit tests with Jasmine/Karma, resulting in the error message below: TypeError: Cannot read property 'modelReplicationStartDate' of undefined error properties: Object({ longStack: 'TypeError: Canno ...

An error in Typescript is indicating that a semicolon is expected. The identifier 'EventNameString' is currently being used as a value, even though it only refers to a type

I've been working on integrating Firebase phone authentication into an older Ionic project and have followed several tutorials. I was able to successfully implement it, but whenever I run ionic serve -l, I encounter the following error: Interestingly ...

The combination of React, Typescript, and MaterialUI Paper results in a stunning design with a sleek and

Whenever I include <Paper elevation={0} /> within my react component, I encounter the following issue: Cannot read properties of undefined (reading 'background') TypeError: Cannot read properties of undefined (reading 'background&apos ...

Using the tensorflow library with vite

Greetings and apologies for any inconvenience caused by my relatively trivial inquiries. I am currently navigating the introductory stages of delving into front-end development. Presently, I have initiated a hello-world vite app, which came to life throug ...

Storing Passport.js Token Locally: Best Practices

Struggling to save the jwt token provided by passport.js in browser localStorage, I am facing challenges with transferring it from the server to the client as it is generated on the server side. If anyone can assist me with setting the server-generated to ...