error while generating angular build

Asked

Viewed 147 times

1

i have an angular design that runs normally in the production environment, but I’m looking to build it and I’m getting the following error when using the npm run build command:

ERROR in Error: Type Imagecroppercomponent in C:/d/Workspaces/Curso Java Workspace/pk2-angular-v1.0.0/node_modules/ng2-img-Cropper/src/imageCropperComponent.d.ts is part of the declarations of 2 modules: Appmodule in C:/d/Workspaces/Java Course Workspace/pk2-angular-v1.0.0/src/app/app.module.ts and Imagecroppermodule in C:/d/Workspaces/Java Course Workspace/pk2-angular-v1.0.0/node_modules/ng2-img-Cropper/src/imageCropperModule.d.ts! Please consider Moving Imagecroppercomponent in C:/d/Workspaces/Curso Java Workspace/pk2-angular-v1.0.0/node_modules/ng2-img-Cropper/src/imageCropperComponent.d.ts to a Higher module that Imports Appmodule in C:/d/Workspaces/Curso Java Workspace/pk2-angular-v1.0.0/src/app/app.module.ts and Imagecroppermodule in C:/d/Workspaces/Java Course Workspace/pk2-angular-v1.0.0/node_modules/ng2-img-Cropper/src/imageCropperModule.d.ts. You can also create a new Ngmodule that Exports and includes Imagecroppercomponent in C:/d/Workspaces/Java Course Workspace/pk2-angular-v1.0.0/node_modules/ng2-img-Cropper/src/imageCropperComponent.d.ts then import that Ngmodule in Appmodule in C:/d/Workspaces/Curso Java Workspace/pk2-angular-v1.0.0/src/app/app.module.ts and Imagecroppermodule in C:/d/Workspaces/Java Course Workspace/pk2-angular-v1.0.0/node_modules/ng2-img-Cropper/src/imageCropperModule.d.ts.

When reading the error I saw that this lib I’m using is part of the statement of two modules (I don’t understand what that means) but let’s go. in my app.module that accuses error I am importing it:

import { ImageCropperComponent } from 'ng2-img-cropper';

and declared in my declarations @Ngmodule. Can someone tell me how to fix it?

  • 2

    Conssegui resolve, I was importing the Component in declarations, but the correct is to import the module in Imports

1 answer

0

You are declaring your component in the 'declarations' (which are the components and directives that belong to it) instead of 'Imports' (which is what it uses).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.