angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Problem with Angular Cli, Build and Routes

Open lennonalvesdias opened this issue 9 years ago • 5 comments

I have a problem with an Angular application, someone help me? When running 'ng serve', everything flowed normally, but when performing 'ng build' and execute to the server, when I refresh the page the application loses the route by returning the following message: 'The requested URL was not found in this Server. '.

When I build the command 'ng build --prod' or 'ng build --prod --aot' some errors appear, such as:

'ERROR in Child compilation failed: Module not found: Error: Can't resolve './.' in '[...]\src\app\admin': Error: Can't resolve './.' in '[...]\src\app\admin'

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '[...]\src' @ ./src/main.ts 4:0-74 @ multi ./src/main.ts'

Despite some similar situations, I have not found any resolution on the internet so far. Thank you for your attention. Hugs.

lennonalvesdias avatar Jun 13 '17 15:06 lennonalvesdias

You will need to configure the web server you're deploying to to redirect requests that can't be handled (404's) to index.html and allow the client application handle routing.

Brocco avatar Jun 14 '17 22:06 Brocco

Hi @lennonalvesdias, did you find a solution for that? I have the same problem and the answer by @Brocco is irrelevant. Thanks.

zohar1000 avatar Apr 30 '18 07:04 zohar1000

Hello @zohar1000. Yes, I did not have any more problems with that. Due to time, I do not remember the exact solution, but I could help you. You already tried use ng build --prod --aot=false or ng build --prod --aot=false --build-optimizer=false ?

lennonalvesdias avatar May 07 '18 18:05 lennonalvesdias

hi @lennonalvesdias , I found out eventually what the problem was. it was a definition in the css, there was an empty url for a background image, something like: background-image: url('') the background image was filled during run time by the .ts script.

It wasn't my code, I was given the task to compile it for aot after the programmer who wrote it and his team leader gave up on trying to find out what the problem was. I found out a bunch of other errors that the aot compiler produces that the jit compiler doesn't, can't understand why they both don't share the same compilation code, but I guess there are reasons.. at least for some errors the angular compiler messages can be improved, that would save us a lot of time on problems like this one (:

on any case thanks for and the help and the willingness :)

zohar1000 avatar May 12 '18 10:05 zohar1000

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.