Windows 10
@angular/cli: 1.0.0-rc.0
node: 7.4.0
os: win32 x64
@angular/cli: 1.0.0-rc.0
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/compiler-cli: 2.4.8
@angular/core: 2.4.8
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/router: 3.4.8
@ngtools/webpack: 1.2.11
ng build work fine, but ng build -prod field with unknown error.
ERROR in Cannot determine the module for class EventDetailsComponent in C:/Users/admin/Desktop/newvent/src/client/app/pages/event/eventDetails/eventDetails.component.ts!
ERROR in ./src/client/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:\Users\admin\Desktop\newvent\src\client'
@ ./src/client/main.ts 5:0-74
@ multi ./src/client/main.ts
You sure that component is part of a module?
Yes.
In the event.module.ts i have EventDetailsComponent in the declarations and exports.
I import the event.module to the page.module.ts.
There all work fine without prod mode.
Make sure you're not using default export in your EventDetailsComponent component. AoT doesn't like defaults.
This is probably due to using export default class
, like @yfain said. Try and come back to us if that doesn't work. We'll reopen.
Same here after updating from 1.0.0-beta.17 to 1.0.0-rc.1
We created a new project using cli and moved all files over as depicted in the RC-update story (https://github.com/angular/angular-cli/wiki/stories-rc-update)
$ ng -v
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ â–³ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.0.0-rc.1
node: 6.9.1
os: darwin x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.1
@angular/compiler-cli: 2.4.9
$ nvm current
v6.9.1
On the other hand, if we force aot=false
, the problem goes away.
$ ng build --bh /prod/ --prod -aot false -op /usr/local/Cellar/nginx/1.10.1/html
$ cat src/environments/environment.prod.ts
export const environment = {
production: true
};
Ideas?
In our case, the error mentioned a custom Pipe.
In src/app/app.module.ts
, it turned out that this pipe was not listed in the declarations
section but instead listed in the providers
section.
After relocating it onto the declarations
section, the ng build --prod ...
command completed successfully with no errors.
Just a head's up in case anyone else is seeing this:
I had a hanging old component at /src/app/comp-name-old
which was a defunct version of a real component at /src/app/comp-name
. It wasn't included anywhere and ng build
worked but ng build --prod
caused the error above. Deleting this extra folder allowed ng build --prod
to work.
I came across this error for a component that actually was imported by my module.
After hours I finally found it.
In my index.ts
file exporting all the components in my component library I had some lowercase letters instead of uppercase in the components file path.
something like:
export { SomeComponent } from './lib/somecomponent'
instead of:
export { SomeComponent } from './lib/someComponent'
Changing it to the exact path - fixed the issue.
Hope this helps somebody...
thank you so much 🎉 the issue is solved
I had a hanging old component at
/src/app/comp-name-old
which was a defunct version of a real component at/src/app/comp-name
. It wasn't included anywhere andng build
worked butng build --prod
caused the error above. Deleting this extra folder allowedng build --prod
to work.
Further details on this - if you need to keep the associated folder around you can remove if from the compile process using the exclude section of tsconfig.json
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._
Most helpful comment
I came across this error for a component that actually was imported by my module.
After hours I finally found it.
In my
index.ts
file exporting all the components in my component library I had some lowercase letters instead of uppercase in the components file path.something like:
instead of:
Changing it to the exact path - fixed the issue.
Hope this helps somebody...