-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ng build -prod Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' #4551
Comments
Having the same failure on both linux and windows platforms. ERROR in Cannot read property 'map' of undefined
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/helix-app.module.ngfactory' in 'C:\Users\agarbutt\WebstormProjects\helix-ui\src'
@ ./src/main.ts 3:0-85
@ multi ./src/main.ts main.ts import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {enableProdMode} from "@angular/core";
import {environment} from "./environments/environment";
import {HelixAppModule} from "./app/";
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic()
.bootstrapModule(HelixAppModule)
.catch(err => console.error(err)); |
+1 |
+1 (on Windows 10 64bits) |
+1
|
This may or may not be helpful but I have noticed that the first error seems to be the primary cause and the Module not found error is generic and will happen any time something breaks the aot build. In my case I was getting the following any time I had an empty scss file:
As soon as I fixed the first error, the Module not found error resolved itself. From that, I would expect @IlyaSurmay and @agarbutt each have different project specific bugs. (Possibly aot compiler related) Can you see if the --verbose flag gives you any more information about the error? |
CTRL+F the document for 'was generated' to find out what command I used: If you want to try it yourself please clone this repo: I have no empty .scss files, and even if I attempt to add something to styles.css in the src folder, I get the same error. |
The same thing happens for me. No error other than:
I had to make a separate, plain client entry point for AOT, but it still doesn't work.
OS: Fedora 25 x64 Also, if that's helpful, my project is using Universal, but AOT is used for client only. |
I think it might be ngc. I cannot make it generate anything even when
running it directly.
16.02.2017 4:43 PM "Ilya Surmay" <notifications@github.com> napisał(a):
… +1
linux mint
ERROR in this._input.charCodeAt is not a function
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/vs/Work/GoFactTables/GoFactFrontend/src'
@ ./src/main.ts 5:0-74
@ multi ./src/main.ts
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4551 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ATNfaOp3L5J0yev2EYWiQmUg8iZvNSx_ks5rdG6GgaJpZM4L7u-Y>
.
|
Same error when I upgraded to 4.0.0-beta.8. Previous version 4.0.0-beta.7 doesn't have this failure. |
This is how I fixed my issues with the last version of angular-cli : With the last version of angular-cli, ng build --prod seems to compile with --aot by default : I didn't know there was good practices to make project working with... |
See next. I found a solution for me. I hope this helps. |
Similar problem with 1.0.0-rc1 on Windows. Running
|
This issue was closed, any advice for people still sufferring from this error? |
Just to tell everyone: I eventually dropped @ngtools/webpack completely from my project and replaced it with @ultimate/aot-loader. AOT now finally works. |
Instead of use UPDATE As many of us (thx) have mention, this doesn't build with aot so, it's the same that the plain ng build at the end (as says @adessilly The most easy workaround (at least for me), was to create a new whole project with the last Angular CLI version, and moves the src folder. It's no straight forward, so please read the migration guide and don't forget to make a backup before. |
@WiL-dev : I can confirm it works fine on 1.0.0-rc1. Thanks! |
@WiL-dev - I'm not sure This leads me to suspect that the cli tool is fine and it's my app that needs some updates before it can be Something I'll look into when I have a bit of time. |
unresolved, --env produces not the same output as --prod |
@russkayairina it's a normal behavior : To make your project working with aot, follow these steps : |
This is still a problem. It happens even with the newly created project from ng new! Full output:
|
I have fixed this issue in my project. In my case, I have found two reasons: 1. I used jade template. You can't use jade with AOT.// My component.
@Component({
selector: 'app-some-component',
template: require('jade-loader!./some-component.jade')(), // <--- This will break AOT bundling.
styleUrls: ['./some-component.styl']
})
export class SomeCompoonent implements OnInit {
// ...
} How to fix: bring html back or turn off AOT. 2. Export an anonymous function by using
|
Very useful @WiL-dev your comment works fine for me. 4.0.0 |
Building with --AOT today Angularcli V1.0.0 ERROR in Cannot assign to a reference or variable! ERROR in ./src/main.ts Build without AOT and then running, no real help. After investigation I found I was using variable name 'year' changing to taxYear resolved issue. Must be a clash with a method somewhere. |
Same here, in August. Any ideas? |
Check your tsconfig: entryModule should have proper app module path |
ng build was showing some error due to a bug in angular cli Fixed by updating build script angular/angular-cli#4551
I executed this command
` |
This command is 100% work for solving this problem. |
Still problem is going on ...
|
Check this #11835 (comment) update to @angular/core 6.1.7 |
project is based on angular 4 |
Then upgrade? 4 vs 6 isn't that hard aside from a few breaking changes with rxjs that can be fixed with just installing rxjs-compat. I just finished migrating an old project running in production made in v4 to v6 in less than a week. I know it's not the solution, but the fix is working in v6. |
May be your angular version is grater than 4.0.0 because of don't work
properly this command.
please check your version.
…On Wed, Sep 26, 2018 at 3:13 AM DARKGuy (Alemar) ***@***.***> wrote:
Check this #11835 (comment)
<#11835 (comment)>
update to @angular/core 6.1.7
project is based on angular 4
Then upgrade? 4 vs 6 isn't that hard aside from a few breaking changes
with rxjs that can be fixed with rxjs-compat. I just finished migrating an
old project running in production made in v4 to v6 in less than a week.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4551 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AoS6xHrNo0XmHbIlkPobxqgLdhM9EXRTks5uepx0gaJpZM4L7u-Y>
.
|
May be your angular version is grater than 4.0.0 because of don't work
properly this command.
please check your version.
…On Wed, Sep 26, 2018 at 2:00 AM matinzd77 ***@***.***> wrote:
This command is 100% work for solving this problem.
npm install ***@***.***
Still problem is going on ...
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/user/Server/v2/Battery-Server-Panel/src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4551 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AoS6xG2E1cUiC2CFJbyXUoZ4DQvVKElfks5ueotSgaJpZM4L7u-Y>
.
|
I had the the same problem. I fixed it by using ng-packagr v3.0.3 instead of v2.4.5 when building the npm-package. |
I have the same issue which you are facing . have you find any solution if yes then please suggest me. |
I know this call is closed, but its the first link I found when googling, so here is my solution.
Using Angular 7.1.4, reason was I enabledIvy after upgrading from 6 to 7.
Removed the flag and all was good. Ivy is still in Beta and should not be used in production see issue 21706 |
For me it was having "rootDir" in my tsconfig.json ... |
For me it worked with this solution. |
/ \ _ __ __ _ _ | | __ _ _ __ / | | | | and this is the error ERROR in ./src/main.ts please suggest solution asap |
@ervivekmahajan please read all the comments asap |
Still having this issue. All the proposed solutions don't work: no absolute paths, rootDir doesnt exist, aot=false doesn't work since buildOptimizer requires AOT. Using Angular 7.2. Any help? |
I still have this issue as well. I checked the various solutions but none worked for me. |
s/@types/googlemaps/index.d.ts (1977,5): Duplicate identifier 'OK'. |
Hello i am using same version but not working. can help how to fixed this Version: @angular/cli: 1.0.0-rc.1 Error |
This solution is not work. This is my package version Angular CLI: 1.7.4 @angular/cli: 1.7.4 |
|
worked for me too |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
OS?
Versions.
@angular/cli: 1.0.0-beta.30
node: 7.4.0
os: win32 x64
@angular/common: 2.4.6
@angular/compiler: 2.4.6
@angular/core: 2.4.6
@angular/forms: 2.4.6
@angular/http: 2.4.6
@angular/platform-browser: 2.4.6
@angular/platform-browser-dynamic: 2.4.6
@angular/router: 3.4.6
@angular/cli: 1.0.0-beta.30
@angular/compiler-cli: 2.4.6
Repro steps.
App started using angular cli
The log given by the failure.
This is from my command line:
ERROR in Unexpected value 'null' declared by the module 'AppModule in C:/Users/T
haniri/Desktop/freecodecamp/myroute/src/app/app.module.ts'
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in
'C:\Users\Thaniri\Desktop\freecodecamp\myroute\src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts
Mention any other details that might be useful.
ng serve works fine, its just ng build -prod
Here are the contents of my main.ts file:
`import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/app.module';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
`
If there is more information needed, please let me know. I am trying to learn how to deploy my Angular website.
The text was updated successfully, but these errors were encountered: