12

I have issues with my client-side code (who doesn't, with any code they write in any language, at one point or another in the development process?) Problem is that I'm writing this code in Google Apps Script, and can't find the js code I am trying to debug/examine for errors. I remember being able to enter a function name, and then click on the returned code to go straight to the code file, and the function in it, but that, for some reason, isn't working here. I try it and this is what I get taken to:

what even is this?!

(I think Caja might have something to do with this...)

I think it's in some VM**** file, but I don't know much about that. How to access that JavaScript code to set some breakpoints?!

7
  • 1
    This could be helpful: mogsdad.wordpress.com/2015/07/22/… Commented Oct 20, 2017 at 21:08
  • This is probably to simplistic but did you put console.log('MyCode') between the script tags. I do this so that I can get a link to my client side code on every refresh. Commented Oct 23, 2017 at 18:02
  • 1
    Do Me a favor @Mike Warren, click on the {} in the above screenshot in bottom Left corner, then it will expand the javascript code. After code is expanded you can find in that file highlight in yellow the exact line in code that is the issue, then take screenshot again!!! Commented Oct 24, 2017 at 16:39
  • @NickTimmer I do that and it gives me this Commented Oct 24, 2017 at 16:56
  • 2
    Hey @MikeWarren you can try the command "debugger" in your JS. Before execute the code leave the Developer tools oppened and it will stop in that place. Commented Oct 26, 2017 at 19:03

2 Answers 2

7
+50

From answer to how can I debug client side javascript (in html pages) in google appscripts

Unfortunately, there is no other good way to debug client side web UI other than with console logs. As you noted the JavaScript/DOM is re-written so you can't use standard Chrome debug tools.

Because of the above, consider using the approach suggested by Mogsdad on Did you know? (You can log to a spreadsheet from client JavaScript!): Write debugging logs to a spreadsheet.

Sign up to request clarification or add additional context in comments.

Comments

0

what about 'debugger'?Write it in the code

2 Comments

Can I have an example use case, please?
Something like this "worked for me"... console.log(JSON.stringify(driveResultsArr)); debugger; console.log(driveResultsArr[0].get("fileName")); While it doesn't show me the code I wrote (my understanding is that it is "rewritten" by the server before being sent to the browser, via en.wikipedia.org/wiki/Caja_project ). But, I could type in commands in the debugger window to inspect variables, etc.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.