Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the line no or file name of js errors?

Tags:

javascript

I am getting a bit tired of errors like these:

enter image description here

It says nothing about what file or what function or what line.

In this case this was the caller line

vm.setDates(new Date(vm.checkin*1000).format('M d Y'), new Date(vm.checkout*1000).format('M d Y'))

And a few functions down in the code was the .format function where the error was..

Is there any way to get better "error directions" than app.bundle.js:12345 ??

like image 383
torbenrudgaard Avatar asked Nov 07 '22 19:11

torbenrudgaard


1 Answers

I think you should use sourcemaps. A sourcemap is a mapping between the generated/transpiled/minified JavaScript file and one or more original source files. The main purpose of sourcemaps is to aid debugging. Basically, if there’s an error in the generated code file, the map can tell you the original source file location. Reference: Sourcemaps.

like image 133
Eduardo Melo Avatar answered Nov 15 '22 12:11

Eduardo Melo