michal.jakubeczy
michal.jakubeczy

Reputation: 9469

Cannot find module {applicationPath}

I am trying to run an application in debug mode from Visual Studio code. When I click debug following error occurs:

A JavaScript error occurred in the main process

Uncaught Exception:
Error: Cannot find module 'C:\electron2\electron_app\--inspect-brk=15965'
    at Module._resolveFilename (internal/modules/cjs/loader.js:602:15)
    at Function.Module._resolveFilename (C:\electron2\electron_app\node_modules\electron\dist\resources\electron.asar\common\reset-search-paths.js:35:12)
    at Function.Module._load (internal/modules/cjs/loader.js:528:25)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at init (C:\electron2\electron_app\node_modules\electron-compile\lib\config-parser.js:294:16)
    at main (C:\electron2\electron_app\node_modules\electron-prebuilt-compile\lib\es6-init.js:58:29)
    at Object.<anonymous> (C:\electron2\electron_app\node_modules\electron-prebuilt-compile\lib\es6-init.js:61:1)
    at Object.<anonymous> (C:\electron2\electron_app\node_modules\electron-prebuilt-compile\lib\es6-init.js:63:3)
    at Module._compile (internal/modules/cjs/loader.js:711:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:722:10)

My debug configuration looks like this

{
    "version": "0.2.0",
    "configurations": [
      {
        "name": "Debug",
        "type": "node",
        "request": "launch",
        "cwd": "${workspaceRoot}",
        "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
        "windows": {
          "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
        },
        "args" : ["."]
      }
    ]
  }

Also one more error caught:

No such module: atom_browser_features

Never heard of such module before.

Used to work before, but all of sudden it stopped to work. Anyone has a clue what the problem might be?

Upvotes: 4

Views: 1936

Answers (2)

Jake Holzinger
Jake Holzinger

Reputation: 6063

You are likely having issues because --inspect-brk=15965 is being interpreted as the "main" script.

Assuming the command line is generated similar to noseratio's:

C:/test/node_modules/.bin/electron.cmd --remote-debugging-port=9223 . --inspect-brk=47365

You can see that --inspect-brk comes after the declared args, however, node arguments must be declared prior to the "main" script. You can try upgrading to [email protected] to see if the issue resolves itself. Alternatively, you could attempt to be more explicit with the entry point like they have done in the electron-quick-start project.

{
    "name": "Debug Main Process",
    "type": "node",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
    "windows": {
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
    },
    "program": "${workspaceRoot}/main.js",
    "protocol": "inspector"
}

Upvotes: 1

Anurag Thakur
Anurag Thakur

Reputation: 21

Instead of "${workspaceRoot}/node_modules/.bin/electron" use "{workspaceRoot}\\node_modules\.bin\\electron" in runtimeexecutable and windows:{runtimeexecutable} as you're using windows I suppose.

Upvotes: 0

Related Questions