1
votes

When I Create Build for my angular 5 Application I am getting the below error.

its working fine when I create build

ng build 

it's showing error when I create buildproductionttion

ng build --prod

i am not using the ngfactory anywhere in my application.

ERROR in ./src/main.ts Module not found: Error: Can't resolve './app/app.module.ngfactory' in 'C:\projects\Project-CMS\Project.Web\src' resolve './app/app.module.ngfactory' in 'C:\projects\Project-CMS\Project.Web\src' using description file: C:\projects\Project-CMS\Project.Web\package.json (relative path: ./src) Field 'browser' doesn't contain a valid alias configuration after using description file: C:\projects\Project-CMS\Project.Web\package.json (relative path: ./src) using description file: C:\projects\Project-CMS\Texakoma.Web\package.json (relative path: ./src/app/app.module.ngfactory) no extension Field 'browser' doesn't contain a valid alias configuration C:\projects\Project-CMS\Project.Web\src\app\app.module.ngfactory doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration C:\projects\Project-CMS\Project.Web\src\app\app.module.ngfactory.ts doesn't exist .js Field 'browser' doesn't contain a valid alias configuration C:\projects\Project-CMS\Project.Web\src\app\app.module.ngfactory.js doesn't exist as directory C:\projects\Project-CMS\Project.Web\src\app\app.module.ngfactory doesn't exist [C:\projects\Project-CMS\Project.Web\src\app\app.module.ngfactory] [C:\projects\Project-CMS\Project.Web\src\app\app.module.ngfactory.ts] [C:\projects\Project-CMS\Project.Web\src\app\app.module.ngfactory.js] [C:\projects\Project-CMS\Project.Web\src\app\app.module.ngfactory] @ ./src/main.ts 4:0-66 @ multi ./src/main.ts

3
Can you share your package.json?axl-code
updated package.json in questionDeveloper
Are you using e2e tests which include the use of browser variable?axl-code
i am not using them. is it creating the problem .?Developer
No, was just to see if you were importing browser from a wrong place (like selenium o something like that)axl-code

3 Answers

-1
votes

I have the same error in angular 5. this works for me

ng build --prod --aot=false

another solution I upgrade my ng version from 5.1.0 to version 5.1.1. it solve the problem without adding --aot=false option.

1
votes

I started getting this error after i used

ng update

and I resolved the issue by reverting my package.json to the previous version of angular,

I downgraded from 6.1.3 to 6.0.7

-2
votes

I had the same issue. Try the build by disabling aot and see if it works. Use ng build --prod --aot=false. If this works then you might want to refer to the link below. It looks like there is a bug, upgrading angular and/or cli should fix it.
https://github.com/angular/angular-cli/issues/8797