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! [email protected] build:prod: `ng build --prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
--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.
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)
I have been recieiving the following after i tried to lazy load my modules for a project of mine:
ERROR in ./src/$$_gendir lazy Module not found: Error: Can't resolve ' src$$_gendir\app\products\product.module.ngfactory.ts' in ' src$$_gendir' resolve ' src$$_gendir\app\products\product.module.ngfactory.ts' in ' src$$_gendir' using description file: package.json (relative path: ./src/$$_gendir) Field 'browser' doesn't contain a valid alias configuration after using description file: package.json (relative path: ./src/$$_gendir) using description file: package.json (relative path: ./src/$$_gendir/app/products/product.module.ngfactory.ts) no extension Field 'browser' doesn't contain a valid alias configuration src$$_gendir\app\products\product.module.ngfactory.ts doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration src$$_gendir\app\products\product.module.ngfactory.ts.ts doesn't exist .js Field 'browser' doesn't contain a valid alias configuration src$$_gendir\app\products\product.module.ngfactory.ts.js doesn't exist as directory src$$_gendir\app\products\product.module.ngfactory.ts doesn't exist [ src$$_gendir\app\products\product.module.ngfactory.ts] [ src$$_gendir\app\products\product.module.ngfactory.ts.ts] [ src$$_gendir\app\products\product.module.ngfactory.ts.js] [ src$$_gendir\app\products\product.module.ngfactory.ts] @ ./src/$$_gendir lazy @ ./node_modules/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts
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...
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:
ERROR in ./src/$$_gendir lazy Module not found: Error: Can't resolve ' src$$_gendir\app\products\product.module.ngfactory.ts' in ' src$$_gendir' resolve ' src$$_gendir\app\products\product.module.ngfactory.ts' in ' src$$_gendir' using description file: package.json (relative path: ./src/$$_gendir) Field 'browser' doesn't contain a valid alias configuration after using description file: package.json (relative path: ./src/$$_gendir) using description file: package.json (relative path: ./src/$$_gendir/app/products/product.module.ngfactory.ts) no extension Field 'browser' doesn't contain a valid alias configuration src$$_gendir\app\products\product.module.ngfactory.ts doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration src$$_gendir\app\products\product.module.ngfactory.ts.ts doesn't exist .js Field 'browser' doesn't contain a valid alias configuration src$$_gendir\app\products\product.module.ngfactory.ts.js doesn't exist as directory src$$_gendir\app\products\product.module.ngfactory.ts doesn't exist [ src$$_gendir\app\products\product.module.ngfactory.ts] [ src$$_gendir\app\products\product.module.ngfactory.ts.ts] [ src$$_gendir\app\products\product.module.ngfactory.ts.js] [ src$$_gendir\app\products\product.module.ngfactory.ts] @ ./src/$$_gendir lazy @ ./node_modules/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts
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
use @angular/[email protected] solved my problem!
please try this command "npm i [email protected]"
The command "npm i [email protected]" solved my problem!!! Thanks
I had the same problem and found out what the problem was.
In my feature module (say TestModule), I had a barrel (index.ts exporting the TestModule.
From the app-routing.module.ts I configures lazy loading: loadChildren: ./test#TestModule.
Here I got the same error as mentioned above.
When importing the module from the module file, the error does not occur anymore.
I changed the lazy loading part to: ./test/test.module#TestModule
This solved the problem for me ;-)
I meed the same trouble when i ran ng build --prod, in my project.
To resolve this error, i had tried these 3 kinds of methods, but all failed:
1.Upgrade @anglar/ to version 4.4.7. 2.Upgrade both @angular/cli --save-dev and -g to version 1.2.7. 3.I also tried installing [email protected],but failed. Current version is 4.1.3.
Now,i totally have no idea, and really hope someone could give me some advices.Thanks!
**Here is my angular info:
@angular/cli:1.2.7
node:7.0.0 os: win32 x64 @angular/animations: 4.4.7 @angular/common: 4.4.7 @angular/compiler: 4.4.7 @angular/core: 4.4.7 @angular/forms: 4.4.7 @angular/http: 4.4.7 @angular/platform-browser: 4.4.7 @angular/platform-browser-dynamic: 4.4.7 @angular/router: 4.4.7 @angular/cli: 1.2.7 @angular/compiler-cli: 4.4.7 @angular/language-service: 4.4.7
错误信息:
ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve 'D:\a\frame\angular2\demo\ag127\src$$_gendir\app\pages\basic\productMng\addProductModule\addProduct.module.ngfactory.ts' in 'D:\a\frame\angular2\demo\ag127\src$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts
And here is my **package.json**:
{ "name": "ag127", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "build-prod": "node --max_old_space_size=5048 "./node_modules/@angular/cli/bin/ng" build --prod" }, "private": true, "dependencies": { "@angular/animations": "^4.0.0", "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", "core-js": "^2.4.1", "rxjs": "^5.4.1", "zone.js": "^0.8.14" }, "devDependencies": { "@angular/cli": "1.2.7", "@angular/compiler-cli": "^4.0.0", "@angular/language-service": "^4.0.0", "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.26", "@ngx-translate/core": "6.0.1", "@ngx-translate/http-loader": "0.0.3", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "ag-grid": "^12.0.2", "ag-grid-angular": "^12.0.0", "ag-grid-enterprise": "^12.0.2", "amcharts3": "github:amcharts/amcharts3", "ammap3": "github:amcharts/ammap3", "angular2-cookie": "^1.2.6", "angular2-datatable": "0.6.0", "animate.css": "3.5.2", "bootstrap": "4.0.0-alpha.6", "bootstrap-table": "^1.11.2", "chart.js": "1.1.1", "chartist": "0.10.1", "chartist-plugin-barlabels": "0.0.5", "chartist-plugin-pointlabels": "0.0.5", "chroma-js": "1.3.3", "ckeditor": "4.6.2", "codelyzer": "~3.0.1", "easy-pie-chart": "2.1.7", "enhanced-resolve": "^3.3.0", "font-awesome": "4.7.0", "fullcalendar": "3.3.1", "gh-pages": "0.12.0", "google-maps": "3.2.1", "heimdalljs-logger": "^0.1.9", "ionicons": "2.0.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "jquery": "3.2.1", "jquery-slimscroll": "1.3.8", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "leaflet": "0.7.7", "leaflet-map": "0.2.1", "lodash": "4.17.4", "ng2-auto-complete": "^0.12.0", "ng2-ckeditor": "1.1.6", "ng2-completer": "1.3.1", "ng2-handsontable": "0.48.0", "ng2-pagination": "^2.0.2", "ng2-slim-loading-bar": "4.0.0", "ng2-smart-table": "1.0.3", "ng2-tree": "2.0.0-alpha.5", "ng2-uploader": "^2.0.0", "ng2-validation": "^4.2.0", "ng2-validation-manager": "^0.3.4", "ngx-bootstrap": "^1.8.1", "ngx-cookie": "^1.0.0", "ngx-uploader": "2.2.5", "node-sass": "^4.9.0", "normalize.css": "6.0.0", "npm-run-all": "4.0.2", "primeng": "^4.1.2", "protractor": "~5.1.2", "rimraf": "2.6.1", "roboto-fontface": "0.7.0", "standard-changelog": "1.0.1", "stylelint": "7.10.1", "tether": "^1.4.0", "ts-md5": "^1.2.2", "ts-node": "~3.0.4", "tslint": "~5.3.2", "tslint-eslint-rules": "4.0.0", "tslint-language-service": "0.9.6", "typescript": "~2.3.3", "typogr": "0.6.6", "underscore": "1.8.3", "wintersmith": "2.2.5", "wintersmith-sassy": "1.1.0" } }
@filipesilva
@gyanstack solution is working but is this correct?
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.