-
Couldn't load subscription status.
- Fork 106
Debugging
By default, devtools only shows logs from the renderer process. In order to debug the main process, we have to explicitly call electron using the --inspect flag. We have already
set up a command to include the flag (i.e. yarn start-debug). The only thing left to do is setup a debugger. The easiest way is to use Chrome; the steps are detailed below.
- Open Chrome and navigate to
chrome://inspect - Click "Open dedicated DevTools for Node"
- Click "Add connection"
- Type in
localhost:5858and click "Add" - From the root directory, run
yarn start-debug - Return to the Node DevTools window and you should see output in the
Consoletab
It is best to use yarn watch-main-dev and yarn watch-electron-dev while debugging because source code is not minified, there are optimizations, and source map is not generated
in non-dev targets.
We can do the same as above, but in WebStorm
- Add a new build configuration
- Press
+ - Choose "Attach to Node.js/Chrome"
- Give it a name and set it to port 5858
- Click "Ok"
- Select the configuration and press the "Debug" button
- Run the appropriate commands (i.e.
yarn build>yarn dist) - From the project root directory:
cd dist/mac/Knowledge\ Canvas.app/Contents - Run
./MacOS/Knowledge\ Canvas
Note that this must be run from the Contents folder
The only difference between this and the above is where the Contents folder is located. In most cases, you must run the command from /Applications/Knowledge Canvas.app/Contents