1 line
6.8 KiB
JavaScript
1 line
6.8 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[382],{440:function(e,n,t){"use strict";t.r(n),t.d(n,"frontMatter",(function(){return a})),t.d(n,"metadata",(function(){return c})),t.d(n,"rightToc",(function(){return u})),t.d(n,"default",(function(){return l}));var r=t(2),o=t(6),i=(t(0),t(467)),a={sidebar_label:"Debugging",title:"Debugging"},c={unversionedId:"guides/debugging",id:"guides/debugging",isDocsHomePage:!1,title:"Debugging",description:"Application Debugging",source:"@site/docs/guides/debugging.md",slug:"/guides/debugging",permalink:"/docs/guides/debugging",editUrl:"https://github.com/nodegui/nodegui/edit/master/website/docs/guides/debugging.md",version:"current",sidebar_label:"Debugging",sidebar:"guides",previous:{title:"Architecture",permalink:"/docs/guides/nodegui-architecture"},next:{title:"Debugging in VSCode",permalink:"/docs/guides/debugging-in-vscode"}},u=[{value:"Application Debugging",id:"application-debugging",children:[]},{value:"Debugging Qode process",id:"debugging-qode-process",children:[{value:"Command Line Switches",id:"command-line-switches",children:[]},{value:"External Debuggers",id:"external-debuggers",children:[]}]}],p={rightToc:u};function l(e){var n=e.components,t=Object(o.a)(e,["components"]);return Object(i.b)("wrapper",Object(r.a)({},p,t,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"application-debugging"},"Application Debugging"),Object(i.b)("p",null,"Whenever your NodeGui application is not behaving the way you wanted it to,\nan array of debugging tools might help you find coding errors, performance\nbottlenecks, or optimization opportunities."),Object(i.b)("p",null,"Since a NodeGui application runs on Qode. And Qode is essentially NodeJs. We can consider a NodeGui app as a regular NodeJs app. Hence, you can use any debugging tool that you use with NodeJs\nOne of the most popular ways of debugging a NodeJs app is by making use of the ",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"https://nodejs.org/en/docs/inspector/"}),"Chromium Developer Tools"),"."),Object(i.b)("p",null,"Google offers ",Object(i.b)("a",Object(r.a)({parentName:"p"},{href:"https://developer.chrome.com/devtools"}),"excellent documentation for their developer tools"),".\nWe recommend that you make yourself familiar with them - they are usually one\nof the most powerful utilities in any NodeGui Developer's tool belt."),Object(i.b)("h2",{id:"debugging-qode-process"},"Debugging Qode process"),Object(i.b)("p",null,"To debug JavaScript that's executed in the Qode/Node process you will need to use an external debugger and\nlaunch Qode with the ",Object(i.b)("inlineCode",{parentName:"p"},"--inspect")," or ",Object(i.b)("inlineCode",{parentName:"p"},"--inspect-brk")," switch. Once you run it you can open up Chrome and visit ",Object(i.b)("inlineCode",{parentName:"p"},"chrome://inspect")," where you should see your app listed."),Object(i.b)("h3",{id:"command-line-switches"},"Command Line Switches"),Object(i.b)("p",null,"Use one of the following command line switches to enable debugging of the process:"),Object(i.b)("h4",{id:"--inspectport"},Object(i.b)("inlineCode",{parentName:"h4"},"--inspect=[port]")),Object(i.b)("p",null,"Qode will listen for V8 inspector protocol messages on the specified ",Object(i.b)("inlineCode",{parentName:"p"},"port"),",\nan external debugger will need to connect on this port. The default ",Object(i.b)("inlineCode",{parentName:"p"},"port")," is\n",Object(i.b)("inlineCode",{parentName:"p"},"9229"),"."),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{className:"language-shell"}),"qode --inspect=9229 your/app\n")),Object(i.b)("h4",{id:"--inspect-brkport"},Object(i.b)("inlineCode",{parentName:"h4"},"--inspect-brk=[port]")),Object(i.b)("p",null,"Like ",Object(i.b)("inlineCode",{parentName:"p"},"--inspect")," but pauses execution on the first line of JavaScript."),Object(i.b)("p",null,Object(i.b)("strong",{parentName:"p"},"Note")),Object(i.b)("p",null,"If you are using the official boilerplate ",Object(i.b)("inlineCode",{parentName:"p"},"nodegui-starter"),", then you can achieve this by running"),Object(i.b)("pre",null,Object(i.b)("code",Object(r.a)({parentName:"pre"},{}),"npm run debug\n")),Object(i.b)("h3",{id:"external-debuggers"},"External Debuggers"),Object(i.b)("p",null,"You will need to use a debugger that supports the V8 inspector protocol."),Object(i.b)("ul",null,Object(i.b)("li",{parentName:"ul"},"Connect Chrome by visiting ",Object(i.b)("inlineCode",{parentName:"li"},"chrome://inspect")," and selecting to inspect the\nlaunched NodeGui app present there."),Object(i.b)("li",{parentName:"ul"},Object(i.b)("a",Object(r.a)({parentName:"li"},{href:"/docs/guides/debugging-in-vscode"}),"Debugging the NodeGui app in VSCode"))))}l.isMDXComponent=!0},467:function(e,n,t){"use strict";t.d(n,"a",(function(){return s})),t.d(n,"b",(function(){return g}));var r=t(0),o=t.n(r);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function c(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?a(Object(t),!0).forEach((function(n){i(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function u(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var p=o.a.createContext({}),l=function(e){var n=o.a.useContext(p),t=n;return e&&(t="function"==typeof e?e(n):c(c({},n),e)),t},s=function(e){var n=l(e.components);return o.a.createElement(p.Provider,{value:n},e.children)},b={inlineCode:"code",wrapper:function(e){var n=e.children;return o.a.createElement(o.a.Fragment,{},n)}},d=o.a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,i=e.originalType,a=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),s=l(t),d=r,g=s["".concat(a,".").concat(d)]||s[d]||b[d]||i;return t?o.a.createElement(g,c(c({ref:n},p),{},{components:t})):o.a.createElement(g,c({ref:n},p))}));function g(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var i=t.length,a=new Array(i);a[0]=d;var c={};for(var u in n)hasOwnProperty.call(n,u)&&(c[u]=n[u]);c.originalType=e,c.mdxType="string"==typeof e?e:r,a[1]=c;for(var p=2;p<i;p++)a[p]=t[p];return o.a.createElement.apply(null,a)}return o.a.createElement.apply(null,t)}d.displayName="MDXCreateElement"}}]); |