Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vscode Debugger Cannot find module

I copypaste launch.json from different project into vscode folder in project folder and substitute paths to files. When i start debugger i got the following error:

Error: Cannot find module 'c:\Users\Anatoly\Desktop\project_folder --inspect=34947' at Module._resolveFilename (module.js:470:15)

Could you please point out to me what may be the reason for such an error? Thank you!

This is launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {   
      "name": "Debug Main Process",
      "type": "node",
      "request": "launch",
      "program": "${workspaceRoot}/app/main.ts",
      "stopOnEntry": false,
      "args": ["."],  
      "cwd": "${workspaceRoot}",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd",
      "outFiles": [  
        "${workspaceRoot}/dist/main.js" 
      ],
      "protocol":"inspector",
      "env": { }, 
      "sourceMaps": true 
    }   
  ]
} 
like image 285
Anatoly Strashkevich Avatar asked Sep 28 '17 14:09

Anatoly Strashkevich


People also ask

How to enable debugger in visual studio code?

To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D. The Run and Debug view displays all information related to running and debugging and has a top bar with debugging commands and configuration settings.

How to debug a Python file in VS code?

If you're only interested in debugging a Python script, the simplest way is to select the down-arrow next to the run button on the editor and select Debug Python File in Terminal.

How to debug c# project in visual studio code?

To start debugging, select F5, or choose the Debug Target button in the Standard toolbar, or choose the Start Debugging button in the Debug toolbar, or choose Debug > Start Debugging from the menu bar. The app starts and the debugger runs to the line of code where you set the breakpoint.

How to set breakpoint in VScode?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.


2 Answers

I ran into this error myself. In my case, I had simply forgotten to run npm install to install all the project's dependencies before trying to debug the program. Silly error on my part.

like image 73
mrbinky3000 Avatar answered Sep 24 '22 22:09

mrbinky3000


I think your program is using the root when when should be using folder. Try ${workspaceFolder}/app/main.ts rather than ${workspaceRoot}.

like image 35
Parker Lindley Avatar answered Sep 24 '22 22:09

Parker Lindley