angular-cli: ng build --prod give Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:\projectpath\src'
- [x ] bug report
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.
dules/@ng-bootstrap/ng-bootstrap/util/util.d.ts
Hash: b8b958c29762fa762c34
Time: 11764ms
chunk {0} polyfills.62c31de27797344f09a6.bundle.js (polyfills) 158 kB {5} [initial] [rendered]
chunk {1} main.0080928b6a891ad4f45d.bundle.js (main) 3.21 kB {4} [initial] [rendered]
chunk {2} styles.4001f4f573259b290c26.bundle.css (styles) 175 bytes {5} [initial] [rendered]
chunk {3} sw-register.b73048fe3d9f8a1e7ae5.bundle.js (sw-register) 232 bytes {5} [initial] [rendered]
chunk {4} vendor.87c63162470e632861f4.bundle.js (vendor) 960 kB [initial] [rendered]
chunk {5} inline.ce192cec606fd32293a6.bundle.js (inline) 0 bytes [entry] [rendered]
ERROR in m.replace is not a function
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:\Users\asahi\ngnode-fullstack\src'
@ ./src/main.ts 5:0-74
@ multi ./src/main.ts
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build:prod"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! ngnode-fullstack@0.0.1 build:prod: `ng build --prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ngnode-fullstack@0.0.1 build:prod script 'ng build --prod'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ngnode-fullstack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ng build --prod
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ngnode-fullstack
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls ngnode-fullstack
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\asahi\ngnode-fullstack\npm-debug.log
Desired functionality.
Should produce production build
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 25
- Comments: 53 (5 by maintainers)
Commits related to this issue
- pin enhanced-resolve to 3.3.0 per https://github.com/angular/angular-cli/issues/5596 — committed to SparksNetwork/sparks-angular-firebase by sdebaun 7 years ago
Solved by #7113
ng build --prod --aot=false executes without problems.
Or can use ng build --env=prod Instead of ng build --prod
Follow https://github.com/angular/angular-cli/issues/4551
@hansl just tried it out with following
package.json
:Still having this issue on
ng build --aot
Slightly different stacktrace, but same error (using ng4):
great, congrats!
but can you tell me what you’ve changed?
I am using lazy loading in my application and getting same error while creating production build. I was doing ng build --prod (giving error)
but once I tried ng build --environment prod (it’s working properly)
for me not work with target (ng build --prod), but working with: ng build --environment prod
use @angular/cli@1.2.6 solved my problem!
@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?
ps: I’m only having this issue when i add the
files
parameter totsconfig.app.json
file.--env=prod
and--prod
are not the same thing. See https://github.com/angular/angular-cli/issues/7113#issuecomment-317472732 for some information about that.make sure your app running with the same cli version that you have created the app, that’s the problem what I met.
@emreavsar when you add the
files
array, you’re telling TS that those are the entry points for your project - and only those!Instead, try using the
include
property.@asadsahi yep did that, i’m working with angular cli 1.0, and angular 4.0 and once i add the
files
totsconfig.app.json
i cannot build withng build --aot
.i did the same in a brand new project and it’s the same.
please try this command “npm i enhanced-resolve@3.3.0”
@Eikc Exactly the same issue, seems it’s become pretty common…
angular 4.2.4 + angular/cli 1.3.2 + typescript 2.4.2
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
Just leaving it here. Solved by https://github.com/angular/angular-cli/issues/7113
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 Module not found: Error: Can’t resolve ‘./$$_gendir/app/app.module.ngfactory’ in ‘/Users/laurel/git/Nanhua.IOT/IOT-master/src/client2/src’ @ ./src/main.ts 4:0-74 @ multi ./src/main.ts
When putting it inside, it works.
but then the compiler cannot find the namespaces declared in the typings file…