This also applies to any language that you compile to JavaScript. To do that, open your project’s tsconfig.json file and make sure the following lines are added to "compilerOptions": If you want to debug an app that is written in TypeScript, enable source maps generation. To do that, create run/debug configurations for each process and start both of these configurations in debug mode. You can also debug both the main and the render processes at the same time. Debugging the render and main processes simultaneously You can select any port you like.)Īlternatively, run the application from the command line with the -remote-debugging-port=9222 option or use an npm script. Open the previously created Node.js configuration for the main process or create a new one and add the -remote-debugging-port=9222 additional option in the Application parameters field. For a built Windows app it’s your_app-win32-圆4/your_app.exe. You can also debug packaged Electron apps – just make sure you specify the path to Electron inside the built app in the Node.js run/debug configuration.įor example, for a built macOS app, that would be your_app.app/Contents/MacOS/your_app. Save the configuration, set the breakpoints, and click Debug on the toolbar. You can also specify the path to a globally installed electron package. If you installed Electron locally, the executable is located in your node_modules project under the. The Electron executable is what you use to start your Electron app from the command line: electron for macOS and Linux or electron.cmd for Windows. as a Node parameter (because we need to run electron. If you want to see what happens on application start, you need to debug the main process.Ĭreate a new run/debug configuration of the type Node.js, specify the path to the Electron executable in the Node interpreter field, and add. In Electron, there are 2 types of processes: the main process, which manages the web pages of your application and handles system events, and the render process, which is related to every individual page of the app and hosts most of the application logic. To get code completion for Node.js APIs, go to Preferences / Settings | Languages and Frameworks | Node.js and click Coding assistance for Node.js. You can also download the file manually from GitHub and link to it.Īfter you restart the IDE, coding assistance for Electron will work, although it will not be listed among the project dependencies: Then specify the path to the electron.d.ts file located in the global node_modules/electron folder: In the New Library dialog that appears, click + and select Attach Files: To do so, go to Preferences / Settings | Languages and Frameworks | JavaScript | Libraries and click Add. To get the proper code completion in this case, you need to add electron.d.ts as a JavaScript library. If Electron is installed as a global dependency, electron.d.ts will not be detected: If you’ve installed Electron as a project dependency (with $npm install –save-dev electron), WebStorm will automatically locate electron.d.ts in the node_modules folder. Starting with Electron v1.6.9, this file is included in the electron node module. The coding assistance for the Electron APIs is provided via the electron.d.ts TypeScript definition file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |