ng build - ERROR in Type component.ts is part of the declarations of 2 modules
OS?
Mac OSX El Capitan - 10.11.6 (15G1004)
Versions.
@angular/cli: 1.0.0-beta.32.3 node: 7.5.0 os: darwin x64 @angular/common: 2.4.8 @angular/compiler: 2.4.8 @angular/core: 2.4.8 @angular/forms: 2.4.8 @angular/http: 2.4.8 @angular/platform-browser: 2.4.8 @angular/platform-browser-dynamic: 2.4.8 @angular/router: 3.4.8 @angular/cli: 1.0.0-beta.32.3 @angular/compiler-cli: 2.4.8
Repro steps.
I upgrade angular-cli from version beta.24 to beta.32.3 To be sure that a have latest configuration i create new project using
ng new PROJECT_NAME
cd PROJECT_NAME
ng serve
and move all my source (src/app , src/environments ...) into new project for that point work perfect when im trying to create new build
ng build --target=production --environment=member
"environmentSource": "environments/environment.ts",
"environments": {
"member": "environments/environment.member.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
Structure ├── app │ ├── member -- AppModule for member │ ├── shared -- re-usable components ( AlertComponent....etc ) │ └── streamer -- AppModule for member
The log given by the failure.
ng build --target=production --environment=member
Hash: 9dec873be13a19995852
Time: 18503ms
chunk {0} polyfills.ba34e862a6514b264221.bundle.js (polyfills) 153 kB {5} [initial] [rendered]
chunk {1} scripts.aaba2b3fd4b70a474bc5.bundle.js (scripts) 297 kB {5} [initial] [rendered]
chunk {2} main.fa8eb4a28da7447c69fd.bundle.js (main) 1.17 kB {4} [initial] [rendered]
chunk {3} styles.c54673cf7c95127ec2ac.bundle.css (styles) 69 bytes {5} [initial] [rendered]
chunk {4} vendor.9509b55039ce49e048a6.bundle.js (vendor) 835 kB [initial] [rendered]
chunk {5} inline.bdb2bb57e8bde2ba7564.bundle.js (inline) 0 bytes [entry] [rendered]
ERROR in Type AlertComponent in /src/app/shared/component/alert.component.ts is part of the declarations of 2 modules: AppModule in /src/app/member/app.module.ts and AlertModule in /src/app/shared/component/alert.module.ts! Please consider moving AlertComponent in /src/app/shared/component/alert.component.ts to a higher module that imports AppModule in /src/app/member/app.module.ts and AlertModule in /src/app/shared/component/alert.module.ts. You can also create a new NgModule that exports and includes AlertComponent in /src/app/shared/component/alert.component.ts then import that NgModule in AppModule in /src/app/member/app.module.ts and AlertModule in /src/app/shared/component/alert.module.ts.
ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/streamer/app.module.ngfactory' in '/Users/tkachenkoartem/Developer/*****/src' @ ./src/main.ts 4:0-83 @ multi ./src/main.ts
same here.... anyone out there
Had a similar error, modifying angular-cli.json seemed to fix this issue.
Before:
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
After:
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
Before build i create new empty project and move source into new project
Hi,
Found the solution. If you the error above still persist then try this:
open angular-cli.json find- "environments": { "source": "environments/environment.ts", "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" }
and replace with: "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" }
Heya, errors like Error encountered resolving symbol values statically mean that there has been some problem in statically analyzing your app.
The CLI always runs statical analysis on code to ensure it will run when compiled with AOT. This may cause a lot of static analysis errors to surface when importing your project into the CLI, or upgrading for older versions where we didn't run this kind of analysis.
A good resource on how to to debug these errors is https://github.com/rangle/angular-2-aot-sandbox#aot-dos-and-donts.
Also the error you got was pretty self descriptive:
ERROR in Type AlertComponent in /src/app/shared/component/alert.component.ts is part of the declarations of 2 modules: AppModule in /src/app/member/app.module.ts and AlertModule in /src/app/shared/component/alert.module.ts! Please consider moving AlertComponent in /src/app/shared/component/alert.component.ts to a higher module that imports AppModule in /src/app/member/app.module.ts and AlertModule in /src/app/shared/component/alert.module.ts. You can also create a new NgModule that exports and includes AlertComponent in /src/app/shared/component/alert.component.ts then import that NgModule in AppModule in /src/app/member/app.module.ts and AlertModule in /src/app/shared/component/alert.module.ts.
@landon-morin and @neosoko I have the same environment configuration still the error persists.
ERROR in Type FileSelectDirective in /Users/aditya/Work/Projects/Aap ki Kitchen/admin-panel-v2/node_modules/ng2-file-upload/file-upload/file-select.directive.d.ts is part of the declarations of 2 modules: FileUploadModule in /Users/aditya/Work/Projects/Aap ki Kitchen/admin-panel-v2/node_modules/ng2-file-upload/file-upload/file-upload.module.d.ts and HomeModule in /Users/aditya/Work/Projects/Aap ki Kitchen/admin-panel-v2/src/app/home/home.module.ts! Please consider moving FileSelectDirective in /Users/aditya/Work/Projects/Aap ki Kitchen/admin-panel-v2/node_modules/ng2-file-upload/file-upload/file-select.directive.d.ts to a higher module that imports FileUploadModule in /Users/aditya/Work/Projects/Aap ki Kitchen/admin-panel-v2/node_modules/ng2-file-upload/file-upload/file-upload.module.d.ts and HomeModule in /Users/aditya/Work/Projects/Aap ki Kitchen/admin-panel-v2/src/app/home/home.module.ts. You can also create a new NgModule that exports and includes FileSelectDirective in /Users/aditya/Work/Projects/Aap ki Kitchen/admin-panel-v2/node_modules/ng2-file-upload/file-upload/file-select.directive.d.ts then import that NgModule in FileUploadModule in /Users/aditya/Work/Projects/Aap ki Kitchen/admin-panel-v2/node_modules/ng2-file-upload/file-upload/file-upload.module.d.ts and HomeModule in /Users/aditya/Work/Projects/Aap ki Kitchen/admin-panel-v2/src/app/home/home.module.ts.
ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/aditya/Work/Projects/Aap ki Kitchen/admin-panel-v2/src' @ ./src/main.ts 4:0-74 @ multi ./src/main.ts
@landon-morin and @neosoko - I also have the same environment configuration and still have the error.
@filipesilva Would you suggest downgrading the Angular-CLI? Or any other dependency?
I've tried both "@angular/cli": "^1.0.0", and "@angular/cli": "^1.0.1", to no effect.
where will i find the angular-cli.json file?
Any update on this? Unfortunately, I am still receiving this error, despite having updated the Angular CLI
@mots88 - my angular-cli.json file is in the main folder. It is not in the SRC folder, but above it.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.