Debugging Electron-Atom script with Visual Studio Code

LeMoussel

Does Electron run on Visual Studio Code ?

If yes, how to setup a simple environment where I can write/webug Atom Electron script using Visual Studio Code ?

For example I with this Test.js script;

var app = require('app');

process.on('uncaughtException', function(error) {
    console.error("ERROR Exception => " + error.stack);
})

app.on('ready', function() {
    console.log('ready!');
    aksjdflkasjdf(); // Caught Exception
})

For Visual Studio Code there is an launch.json configuration file but I don't say how to setup Visual Studio Code ready for Electron work.

Shawn Rakowski

The answer depends on whether you want to debug the Main process or a Renderer process.

Main Process:

It is possible to debug the Main process using Visual Studio Code. You must pass --debug=<port> into Electron on startup and then configure the debugger in launch.json to attach to it. Attaching takes a little while so you may need to put a wait in to debug the parts that run on startup. Your launch.json file should have this:

    {
        "name": "Attach",
        "type": "node",
        "address": "localhost",
        "port": <port>,
    }

Alternatively, there is a way to configure Visual Studio Code to run Electron and attach the debugger in the same process. Check this thread here: Can Visual Studio Code be configured to launch electron. I also wrote about how to set this up on my blog here: https://mylifeforthecode.github.io/getting-started-with-electron-in-visual-studio-code/ and here: https://mylifeforthecode.github.io/a-better-way-to-launch-electron-from-visual-studio-code/

Renderer Process:

I am not aware of a way to debug a renderer process with Visual Studio Code. Per their documentation:

Today we have good debugging support for Node.js (JavaScript and TypeScript) on all platforms and experimental support for mono (C# and F#) on OS X and Linux. At //build we highlighted the support we are adding for ASP.NET 5 and we plan to add more.

Check out https://code.visualstudio.com/docs/debugging. Note there is no mention of JavaScript in the browser.

However, you can use Chrome's DevTools to debug these processes. Call the openDevTools() or toggleDevTools() method on the BrowserWindow and you'll get the same set of tools that you do if you press F12 in Chrome. There are some timing issues you'll need to work out to get the debugger attached. See this thread: Atom Electron - Detect Dev Tools ready for a work around. I also wrote about this on my blog here: https://mylifeforthecode.github.io/debugging-renderer-process-in-electron/.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Debugging Electron-Atom script with Visual Studio Code

From Dev

Visual Studio Code debugging with AngularJS

From Dev

Visual Studio Code - Debugging a spawned process

From Dev

Visual Studio Code debugging client side JavaScript

From Dev

debugging in Visual Studio Code with babel-node

From Dev

Set protractor arguments debugging in visual studio code

From Dev

Debugging Scrapy Project in Visual Studio Code

From Dev

Execute code only while debugging with Visual Studio

From Dev

Debugging MSTest Unittests in Visual Studio Code

From Dev

Linux Subsystem for Windows: Atom and Visual Studio Code close immediately

From Dev

Debugging xUnit tests in .NET Core and Visual Studio Code

From Dev

Pressing break while debugging in Visual Studio - annoying "Code Not Running"

From Dev

Debugging in Unity (C#) + Visual Studio Code Work on OS X?

From Dev

Debugging a node app hosted on a VM using Visual Studio Code

From Dev

Debugging node.js in Visual Studio Code preview on OS X

From Dev

Can't step over code in Visual studio while debugging

From Dev

GUI Debugging server app using Visual Studio Code

From Dev

SPFx breakpoints and debugging from Visual Studio Code instead from Chrome

From Dev

Dynamic debugging with visual studio

From Dev

Visual Studio debugging WebApi

From Dev

Visual Studio debugging WebApi

From Dev

Dynamic debugging with visual studio

From Dev

Debugging Visual Studio

From Dev

Debug Java Script code in Visual Studio 2010

From Dev

Visual Studio 2015 Debugging vs Not Debugging Views

From Dev

Debugging Azure functions in Visual Studio

From Dev

Visual Studio Debugging with Source Maps

From Dev

Debugging in Visual Studio 2013 express

From Dev

Visual Studio mixed projects debugging

Related Related

  1. 1

    Debugging Electron-Atom script with Visual Studio Code

  2. 2

    Visual Studio Code debugging with AngularJS

  3. 3

    Visual Studio Code - Debugging a spawned process

  4. 4

    Visual Studio Code debugging client side JavaScript

  5. 5

    debugging in Visual Studio Code with babel-node

  6. 6

    Set protractor arguments debugging in visual studio code

  7. 7

    Debugging Scrapy Project in Visual Studio Code

  8. 8

    Execute code only while debugging with Visual Studio

  9. 9

    Debugging MSTest Unittests in Visual Studio Code

  10. 10

    Linux Subsystem for Windows: Atom and Visual Studio Code close immediately

  11. 11

    Debugging xUnit tests in .NET Core and Visual Studio Code

  12. 12

    Pressing break while debugging in Visual Studio - annoying "Code Not Running"

  13. 13

    Debugging in Unity (C#) + Visual Studio Code Work on OS X?

  14. 14

    Debugging a node app hosted on a VM using Visual Studio Code

  15. 15

    Debugging node.js in Visual Studio Code preview on OS X

  16. 16

    Can't step over code in Visual studio while debugging

  17. 17

    GUI Debugging server app using Visual Studio Code

  18. 18

    SPFx breakpoints and debugging from Visual Studio Code instead from Chrome

  19. 19

    Dynamic debugging with visual studio

  20. 20

    Visual Studio debugging WebApi

  21. 21

    Visual Studio debugging WebApi

  22. 22

    Dynamic debugging with visual studio

  23. 23

    Debugging Visual Studio

  24. 24

    Debug Java Script code in Visual Studio 2010

  25. 25

    Visual Studio 2015 Debugging vs Not Debugging Views

  26. 26

    Debugging Azure functions in Visual Studio

  27. 27

    Visual Studio Debugging with Source Maps

  28. 28

    Debugging in Visual Studio 2013 express

  29. 29

    Visual Studio mixed projects debugging

HotTag

Archive