-
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 give Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:\projectpath\src' #5596
Comments
I'm seeing this as well. Seems like something changed in Angular 4.0.0-rc.6. If you downgrade to rc.5 production builds work again. |
@chuckjaz just confirmed that this error has been solved on @angular/angular master and will be in Angular 4.0 final. |
Heya, I'm told that this was a bug in Angular 4.0.0-rc.6 and that i's now fixed. I'm sorry but I don't have an issue to link here. It should be out next release. |
@hansl just tried it out with following
Still having this issue on
|
Slightly different stacktrace, but same error (using ng4):
|
ps: I'm only having this issue when i add the |
Hi guys, Good, news. Its work for me now. I am on angular 4 and cli 1 final. |
great, congrats! but can you tell me what you've changed? |
@emreavsar I haven't modiefied config wise in my project to make it work, just angular/cli and angular packages upgraded to 1 and 4 respectively. If you are using angular cli the default tsconfig.app.json doesn't have files config in it. Just excluding e2e and spec files in exclude settings. I also uninstalled global angular/cli package and then installed 1.0.0 globally as well. One thing I haven't tried is doing npm install with yarn. I have |
One thing also worth trying to generate a new cli project and quickly compare the settings of your local project with the new one. I have been doing the same since all the last releases of cli and always finding something has changed in config file. e.g final vs last rc, tsconfig.json files are slightly different. |
@asadsahi yep did that, i'm working with angular cli 1.0, and angular 4.0 and once i add the i did the same in a brand new project and it's the same. |
with the |
nope, default cli doesn't have files config in tsconfig.app.json. BTW do you need to specify files in config files? |
Without it works as well for me, after adding I have local (non npm) typings, which i need in my project:
|
can you try adding your custom typings in src/typings.d.ts file (default d.ts file generated by cli)? |
@emreavsar you have the |
Valid configuration would look like this: {
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": [],
"typeRoots": [
"../node_modules/@types"
],
"files": [
"../typings/index.d.ts"
]
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
} |
@yarrgh wrong belief :). Not inside compiler options. Schema isn't validated. |
True, but try placing it inside and see if |
Ill try it out at home. |
@yarrgh the reason why it might be compiling is because it is ignoring those files at all. If it is working it might well be a typescript bug unless I am missing something. |
Yeah it is really strange. Doubling it up to where it is both inside and outside of Works: (only inside {
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": [],
"typeRoots": [
"../node_modules/@types"
],
"files": [
"../typings/index.d.ts"
]
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
} Works: (both inside and outside {
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": [],
"typeRoots": [
"../node_modules/@types"
],
"files": [
"../typings/index.d.ts"
]
},
"exclude": [
"test.ts",
"**/*.spec.ts"
],
"files": [
"../typings/index.d.ts"
]
} Doesn't work: (only outside {
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": [],
"typeRoots": [
"../node_modules/@types"
]
},
"exclude": [
"test.ts",
"**/*.spec.ts"
],
"files": [
"../typings/index.d.ts"
]
} |
When putting it inside, it works. but then the compiler cannot find the namespaces declared in the typings file... |
@emreavsar when you add the Instead, try using the |
Jep also read about that in the meanwhile, but it does not change anything, same result. |
@emreavsar can you open a new issue with a simple repro please? That way we can investigate. |
@asadsahi I'm facing the errors but I'm lazy loading modules. It seems it can't find the modules I'm trying to lazy loading. This is my routes setup: app-routing.ts
ng build --prod errors:
package.json:
Is there anything special I have to do to get aot working? |
I got similar Error both in angualr 2 and angular 4 ERROR in Unexpected value 'null' declared by the module 'PageModule in /Users/laurel/git/Nanhua.IOT/IOT-master/src/client2/src/app/pages/routing.module.ts' ERROR in ./src/main.ts |
ng build --prod --aot=false executes without problems. Or can use Follow #4551 |
Strange this issue is closed. I still have the issue with angular cli 1.0.1 (tried with 1.0.0 as well) and angular 4.0.1 (tried with 4.0.0 as well).
Any suggestions would be highly appreciated! |
Ok, so I figured out what's wrong.
The errors says:
When building directly in the e:\temp folder, it works fine:
|
make sure your app running with the same cli version that you have created the app, that's the problem what I met. |
Any update on this guys ? |
Happens to me when It will look in the wrong directory:
notice |
Just leaving it here. |
Solved by #7113
|
for me not work with target (ng build --prod), but working with: ng build --environment prod |
@Apee any idea why this approach works and why this happened? Thanks for the fix! |
@brian-singer I have not idea, my guess is that they updated ng-tools but i'm really not sure what happenned too... If someone has the complete explanation i'd be very happy to know what caused this. |
|
I am using lazy loading in my application and getting same error while creating production build. but once I tried |
I have been recieiving the following after i tried to lazy load my modules for a project of mine:
and i tried all of the different approaches, even changing the enhanced-resolve package.. Nothing worked.. but one thing I noticed was that I actually had my "product" module within a Product folder (with capital P). When I changed the folder naming to lowercase.. my two modules that gave the above error started to compile in --prod mode.. I don't know if this will help anyone but it sure fixed my issues with angular cli AOT / prod |
@Eikc Exactly the same issue, seems it's become pretty common...
|
use @angular/cli@1.2.6 solved my problem! |
please try this command "npm i enhanced-resolve@3.3.0" |
The command "npm i enhanced-resolve@3.3.0" solved my problem!!! Thanks |
I had the same problem and found out what the problem was. In my feature module (say When importing the module from the module file, the error does not occur anymore. This solved the problem for me ;-) |
I meed the same trouble when i ran 1.Upgrade @anglar/ to version 4.4.7. Now,i totally have no idea, and really hope someone could give me some advices.Thanks! **Here is my angular info:
错误信息:
|
And here is my { |
@gyanstack solution is working but is this correct? |
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. |
Versions.
@angular/*": "4.0.0-rc.6
@angular/cli: 1.0.0-rc.4
node: 6.9.1
os: win32 x64
Windows 7 And Window 10
Repro steps.
Just run ng build --prod
The log given by the failure.
Desired functionality.
Should produce production build
The text was updated successfully, but these errors were encountered: