# How to REMOTE debug with VS code?

**URL:** <https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067>\
**Category:** General\
**Created:** [10 October 2021 14:31 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067 "2021-10-10T14:31:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [10 October 2021 14:31 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/1 "2021-10-10T14:31:21Z")

</div>

Since I could not set up remote debugging with the big Visual Studio 2017:

- I've red all topics related here,
- took the advice
- and finally was able install VS code so it can see and edit the .js files on my Raspberry Pi.
- also installed extensions I've thought it may be necessary.

That's great (that I do not have to copy the .js and .html files over and over, but directly edit on the Pi) **but I still can not debug.**

I've tried to upgrade Node-Red to 1.x to the latest (with the recommended script) \>\> now the whole directory I was developing GOT DELETED ! (Lucky me I've backed up... still, very frightening.)

- How do I prevent this next time happening?
- What else do I have to do so the code stops running at the "red break-points"?

 ![kép](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/345fe4e13dd20bde41d9f2cd15db4111e23b58f8.png)

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [10 October 2021 14:39 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/2 "2021-10-10T14:39:27Z")

</div>

Hi,  
Have a look [at this](https://it.knightnet.org.uk/kb/nr-qa/vscode-debugger/), looks good explained to me, didn't used it myself yet.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [10 October 2021 15:01 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/3 "2021-10-10T15:01:46Z")

</div>

/usr/bin/npm run-script debug  
(node:5585) [INSPECTOR\_ASYNC\_STACK\_TRACES\_NOT\_AVAILABLE] Warning: Warning: Async stack traces in debugger are not available on 32bit platforms. The feature is disabled.

Process exited with code 1

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [10 October 2021 15:13 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/4 "2021-10-10T15:13:52Z")

</div>

> [@PizzaProgram](#):
>
> How do I prevent this next time happening?

I assume you mean the folder being deleted? Well, you would need to understand what caused it. Certainly just using npm to install a new version of Node-RED doesn't do that and I don't believe running Dave's script would either.

Ultimately though, while Node-RED is amazingly stable and robust, it is still just a collection of code and so can go wrong easily enough.

Backups are your one and only friend.

I have 3 scripts. a Daily backup, a weekly backup and a monthly backup. The 1st keeps 7 daily backups, the 2nd 5 weekly backups, and the 3rd 12 monthly backups. They currently take up 320M & I've shared the scripts previously, they use rsync to keep things efficient.

> [@PizzaProgram](#):
>
> What else do I have to do so the code stops running at the "red break-points"?

You need to set an initial breakpoint in settings.js if I remember.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [10 October 2021 15:50 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/5 "2021-10-10T15:50:16Z")

</div>

> [@TotallyInformation](#):
>
> Certainly just using npm to install a new version of Node-RED doesn't do that and I don't believe running Dave's script would either.

Sadly: **YES, it did.** (Not the first time, that's why I've made a backup before that.)

If I develop a component, and change the JSON file, it seems it does not match with original on the server (since it is not stable, so It's not merged / uploaded there yet.)  
So somehow it gets completely deleted.  
IMHO NPM should not be trusted.

> [@TotallyInformation](#):
>
> You need to set an initial breakpoint in settings.js if I remember.

- How do I do that?
- Will it help with the "32 bit ... " error above? _(I don't think it has anything to with it does it?)_

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [10 October 2021 23:26 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/6 "2021-10-10T23:26:52Z")

</div>

> [@PizzaProgram](#):
>
> Sadly: **YES, it did.** (Not the first time, that's why I've made a backup before that.)

Not suggesting something didn't cause it.

Actually, I think that must be something local to you since otherwise I think we would see a lot more noise in the forum here and I don't believe we do.

> [@PizzaProgram](#):
>
> If I develop a component, and change the JSON file, it seems it does not match with original on the server (since it is not stable, so It's not merged / uploaded there yet.)  
> So somehow it gets completely deleted.

Urm, not really sure what you are doing there. Are you making changes to the flow json file somewhere else and then using npm to update on another device?

> [@PizzaProgram](#):
>
> IMHO NPM should not be trusted.

There are plenty of failings with npm but it would seem that you are doing something slightly odd here - if you could perhaps explain a little more what you are doing?

> [@PizzaProgram](#):
>
> How do I do that?

You add the `debugger` keyword somewhere in the file. doesn't have to be inside the exports section. I've not done it for ages so I'm a little sketch on it.

You still have to run Node-RED the `--inspect` keyword, something like:

```auto
node --inspect node_modules/node-red/red.js --userDir ./data

```

Obviously, you need to change the paths according to your own setup.

> [@PizzaProgram](#):
>
> Will it help with the "32 bit ... " error above? _(I don't think it has anything to with it does it?)_

Couldn't really say since I've never tried to debug on a 32bit system. Also it may depend on how you are running things. Not sure.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [11 October 2021 03:55 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/7 "2021-10-11T03:55:34Z")

</div>

> [@TotallyInformation](#):
>
> You still have to run Node-RED the `--inspect` keyword

Wow! That's new to me! This could be it...  
But I never used the keyword `node` to start node-red, only `node-red-start`.  
If I simply type `node` into a SSH terminal, it starts some kind of editor.  
Also I don't know what directory this `./data` is?

> [@TotallyInformation](#):
>
> I've never tried to debug on a 32bit system

Almost all Raspberry Pi systems are 32 bit by default! That's why it's interesting, why nobody is complaining about this error...  
The [GitHub ticket](https://github.com/microsoft/vscode-chrome-debug-core/issues/321) has been made read-only too.

PS: Thank you for your help! 🙂

---

<div class="post-metadata">

**Author:** ![mdkrieg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mdkrieg/32/39091_2.png) [@mdkrieg](https://discourse.nodered.org/u/mdkrieg)\
**Post date:** [11 October 2021 04:16 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/8 "2021-10-11T04:16:17Z")

</div>

I’ll chime in that I once had all my flows blanked out (tabs were still there but all were empty) this was also on a pi. Wasn’t able to pin what exactly caused it, I was probably doing something weird, but the lesson was learned - there’s no replacement for regular backups.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [11 October 2021 04:18 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/9 "2021-10-11T04:18:24Z")

</div>

I have changed the version numbers (from 1.xxx to 2.yyy) in the `package.json` file.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 October 2021 08:49 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/10 "2021-10-11T08:49:24Z")

</div>

> [@PizzaProgram](#):
>
> Wow! That's new to me! This could be it...  
> But I never used the keyword `node` to start node-red, only `node-red-start` .  
> If I simply type `node` into a SSH terminal, it starts some kind of editor.

Well, if you want to get into deep debugging, you need to lift up the covers and peer within a little 🙂

> [@PizzaProgram](#):
>
> Also I don't know what directory this `./data` is?

If you type just `node`, you are in a Node.js "REPL" - an interactive Node.js command line shell. The command I showed runs Node.js with 2 arguments, the `--inspect` and the javascript file to run (red.js). The final argument is one for Node-RED rather than Node.js, it tells Node-RED where to find its userDir folder (that contains all of the config, flows, etc).

I never run Node-RED as a global install, I always run it as a local install with the userDir folder within the folder that Node-RED is installed to. See the alternate installer repo on my GitHub for details.

Depending on how you have installed Node-RED, both the location of the RED.js file and the location of your userDir may be different.

> [@PizzaProgram](#):
>
> Almost all Raspberry Pi systems are 32 bit by default! That's why it's interesting, why nobody is complaining about this error...

ARMv7 and below are 32-bit. AMRv8 introduces the 64-bit instruction set. Type the command `lshw` to see what you have.

Typically Pi3 and below run 32-bit and Pi4 runs 64-bit I believe but I think that the Pi3 _can_ run 64-bit (I've not tested it).

> [@PizzaProgram](#):
>
> The [GitHub ticket](https://github.com/microsoft/vscode-chrome-debug-core/issues/321) has been made read-only too.

That's because the repository that it refers to is no longer in use and has been deprecated.

THe "error" is only a warning anyway so debugging should still work.

> [@PizzaProgram](#):
>
> IMHO NPM should not be trusted.

I think that this statement is not correct. This has nothing to do with npm.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 December 2021 08:50 UTC](https://discourse.nodered.org/t/how-to-remote-debug-with-vs-code/52067/11 "2021-12-10T08:50:15Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
