How to debug the main process code of Electron application on VSCode
The knowledge of this article "how to debug the main process code of Electron application on VSCode" is not understood by most people, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to debug the main process code of Electron application on VSCode" article.
Build an environment
The project used in this article is electron-quick-start.
$git clone https://github.com/electron/electron-quick-start$ cd. / electron-quick-start$ npm install
After the above steps, the basic Electron application development environment is built. View package.json:
{"name": "electron-quick-start", "version": "1.0.0", "description": "A minimal Electron application", "main": "main.js", "scripts": {"start": "electron."}, "repository": "https://github.com/electron/electron-quick-start"," keywords ": [" Electron "," quick "," start "," tutorial " "demo"], "author": "GitHub", "license": "CC0-1.0"," devDependencies ": {" electron ":" 16.0.6 "}}
We can run npm run start on the terminal to view the running result:
As you can see, the construction of the environment has been completed! Next, let's move on to the development and debugging process.
Debug configuration
To open it using VSCode, do the following:
Generate the lauch.json file for the following configuration:
{/ / use IntelliSense to learn about the relevant properties. / / hover to see a description of an existing property. / / for more information Please visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [{"type": "pwa-node", "request": "launch", "name": "Launch Program", "skipFiles": ["/ *"] "program": "${workspaceFolder} / main.js"]}
We modify the configuration as follows:
{"version": "0.2.0", "configurations": [{"name": "Debug Main Process", "type": "node", "request": "launch", "cwd": "${workspaceFolder}", "runtimeExecutable": "${workspaceFolder} / node_modules/.bin/electron" "windows": {"runtimeExecutable": "${workspaceFolder} / node_modules/.bin/electron.cmd"}, "args": [. / main.js " / / main file path]}]} above is the content of the article on "how to debug the main process code of Electron applications on VSCode" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.