In the console, I get an undesired location of a log that I placed in an angular component of a project that I am building.
Instead of getting the location of the log in my project e.g.
Hello world myComponent.js:33
I get:
Hello world main.js:333
This is an image of the problem and the desired result:
https://i.stack.imgur.com/oxcPr.jpg
https://i.stack.imgur.com/einkR.png
How to Show in the Console the Correct Location of a log in an Angular Component instead of main.js?
Asked
Active
Viewed 859 times
1

Fabian
- 11
- 2
-
Are you by any chance building your code into a single file? (called main.js) If so - the browser is not aware of this fact. Consider checking [source maps](https://stackoverflow.com/questions/42118760/what-are-the-map-files-used-for-in-angular-cli-and-can-ng-build-not-create-thes) in order to help your browser figure out what the original file is. If you are using a logging tool (like sentry) you presumably need to integrate your source maps with it too. – Benjamin Gruenbaum Feb 17 '21 at 15:41
-
Hello Benjamin. Thank you for your answer. I have written the code of my project into different files and folders, I checked the file tree of the project in vscode and none of them is called main.js. This is a link to an image of the problem, I hope that it usefull: https://imgur.com/a/CB2SEQK – Fabian Feb 17 '21 at 15:56
2 Answers
0
I tried to edit this post to add this image to be more specific but there there is no edit button.

Fabian
- 11
- 2
0
How are you running the project? Seems like Angular is building the app before serving... When you build your project Angular transforms all your components code into a single main.js file.
-
Hello João. Thank you for your reply. In the terminal, I ran ng serve then the program compiles then in the browser I open http://localhost:4200/. This problem only happens after the computer wakes up from sleep mode. I think I once ran ng build in the terminal but I am not sure. This is an image of the problem: https://imgur.com/a/CB2SEQK – Fabian Feb 18 '21 at 14:42