Settings file not found on debugging with vscode

Hey i have started a debug session with vscode.

My launch.json look likes the following. And when i start to debug it cannot found the settings file. But why there is an settings next to red.js !?

{
    "version": "0.2.0",
    "configurations": [        
       {
           "type": "node",
           "request": "launch",
           "name": "Launch Program",
           "skipFiles": [
               "<node_internals>/**"
           ],
           "env": { "NODE_ENV": "development" },
           "preLaunchTask": "npm: build-dev",
           "program": "${workspaceFolder}\\packages\\node_modules\\node-red\\red.js"
       }
    ]
 }

[nodemon] 2.0.6
Gruntfile.js:537
[nodemon] to restart at any time, enter rs
Gruntfile.js:537
[nodemon] watching path(s): packages\node_modules***
Gruntfile.js:537
[nodemon] watching extensions: js,html,json
Gruntfile.js:537
[nodemon] starting node packages/node_modules/node-red/red.js -V
Gruntfile.js:537
> Error loading settings file: \Users\denis.node-red\settings.js
packages/node_modules/node-red/red.js:139
[nodemon] clean exit - waiting for changes before restart
Gruntfile.js:537

Are you running from SRC or NPM install?

from git src

Ok, so I initially installed from NPM & ran node-red which creates c:\users\user\.node-red (though I am sure that should work running from src)

I note you have preLaunchTask set (so you probably got your original vscode settings from one of my earlier posts) but did you also add the entry to tasks.json?

{
    "version": "2.0.0",
    "tasks": [
         {
			"type": "npm",
			"script": "build-dev",
			"group": "build",
			"problemMatcher": [],
			"label": "npm: build-dev",
			"detail": "build-dev"
         }
    ]
}

And when you hit F5 does it run the build pre-task?

Lastly, paste a copy of the debug output (from Pressing F5 to running)

So i have this launch.json and now its running, but is it okay?

{
    "version": "0.2.0",
    "configurations": [
     
      {
        "type": "node",
        "request": "launch",
        "name": "Launch Node-red",
        "program": "${workspaceFolder}\\packages\\node_modules\\node-red\\red.js",
        "runtimeArgs": ["--preserve-symlinks", "--experimental-modules"],
        "env": {
          "NO_UPDATE_NOTIFIER": "1"
        },
        "args": [ "-s", "${workspaceFolder}\\packages\\node_modules\\node-red\\settings.js" ]
      },
      {
        "type": "node",
        "request": "launch",
        "name": "Debug Current File",
        "program": "${file}"
      },
      { "type": "node", "request": "attach", "name": "Attach to Process", "processId": "${command:PickProcess}" } 
      
    ]
  }

Not really. That is using the SRC settings.js - that shouldnt be used or modified.

What you need to understand is, when node-red is ran for the first time, it creates c:\users\user\.node-red folder with a flows file and settings file etc.

Also, that version of launch.json doesnt build node-red src so you'd have to run npm: build-dev every time manually before hitting F5.

If you use the first version and answer my prev questions I will try to help.

Also, can i ask, what is your intent? is this for modifying node-red core or for debugging function nodes you have written in node-red editor or for debugging own custom node development?

hm okay i will try.

my intent is to develop an new node - btw. is there an extension in vscode that will intellisense the "customnode.js" from my newly created node ?

Example:
in the example node if creating a new node there is a line like
msg.payload = msg.payload.toUpperCase();
Here i find its very exhausting to know every method? But its complicated because payload is "any" !?
So i'm searching for an intellisense extension?!

There is not. payload can be anything by design.

however, if you mean inteliisense for things like node and javascript function then use jsdoc to instruct vscode of the type...

/** @type {string} */ var payload = msg.payload */ 


Ok, so you dont need to run node-red from src.

all you need to do is...

  • follow the normal NPM install from node-red docs
  • run node-red once (i.e. node-red) to generate the flows and settings files
  • use this guide to run node-red in vscode
1 Like

Okay thanks!

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