0

When I open the devtools to find out where the error occured in browser, then I typically see something like this:

Cannot read properties of null .... app.js:123123

at MyComponent

It is ok that console gives me that the error occured in MyComponent , but it gives me that the line was in app.js:123123 which is the builded js file I think, so it is hard to find in which line was the error.

I tried using Erorboundaries and try-catch console.log error.stack but it did not gave me exact component with the line.

John
  • 3
  • 2
  • Are talking about built code?, normally in Development mode you will get map files, that will point you to your original code. – Keith Jun 15 '23 at 08:47
  • @Keith You mean "npm run dev" ? I tried it but the console gives me the same app.js:123123 – John Jun 15 '23 at 08:56

1 Answers1

0

When the GENERATE_SOURCEMAP is enabled a full copy of your app's source code is bundled alongside the "minified" / "transcompiled" version of JS files.

If you enable this (GENERATE_SOURCEMAP=true), the original source files will be visible to your app's visitors using tools like browser "Dev Tools".

And if you turn it off (GENERATE_SOURCEMAP=false), it won't create the source map files when you build your project (source maps are generated by default in production mode in CRA). for more refence i am attaching the link reference

Sweety SK
  • 351
  • 1
  • 10