Electron-forge: vscode-nix script cannot find the other executables

Created on 24 Dec 2019  路  4Comments  路  Source: electron-userland/electron-forge

Preflight Checklist

Issue Details

  • Electron Forge Version:

    • 6.0.0-beta.47

  • Electron Version:

    • v7.1.7

  • Operating System:

    • macOS 10.15.2

Expected Behavior

Using the launch configuration from https://www.electronforge.io/advanced/debugging in VS Code enables debugging for the new application.

Actual Behavior

The launch configuration errors with:

/Users/liamdawson/w/orcharduml/node_modules/.bin/electron-forge-vscode-nix --inspect-brk=35706 
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '/Users/liamdawson/w/@electron-forge/cli/dist/electron-forge-start'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

To Reproduce

  • yarn v1.21.1
  • npm v6.13.4
  • node v10.16.3

Additional Information

I'm guessing it's related to something about package nesting and/or symlinks?

Bug

Most helpful comment

to fix it the electron-forge-vscode-nix file must be change from

#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

ARGS=$@
ARGS=${ARGS// /\~ \~}

node $DIR/../../../@electron-forge/cli/dist/electron-forge-start --vscode -- \~$ARGS\~

to

#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

ARGS=$@
ARGS=${ARGS// /\~ \~}

node $DIR/../@electron-forge/cli/dist/electron-forge-start --vscode -- \~$ARGS\~

All 4 comments

same issue. The problem is
Error: Cannot find module '/Users/liamdawson/w/@electron-forge/cli/dist/electron-forge-start'
but it missing node_modules in path 馃

to fix it the electron-forge-vscode-nix file must be change from

#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

ARGS=$@
ARGS=${ARGS// /\~ \~}

node $DIR/../../../@electron-forge/cli/dist/electron-forge-start --vscode -- \~$ARGS\~

to

#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

ARGS=$@
ARGS=${ARGS// /\~ \~}

node $DIR/../@electron-forge/cli/dist/electron-forge-start --vscode -- \~$ARGS\~

I got the same issue on version 6.0.0-beta.52. So how about the following patch to the file electron-forge/packages/api/cli/script/vscode.sh:

#!/usr/bin/env bash
DIR="$( dirname "$( realpath "${BASH_SOURCE[0]}" )" )"

ARGS=$@
ARGS=${ARGS// /\~ \~}

node $DIR/../../../@electron-forge/cli/dist/electron-forge-start --vscode -- \~$ARGS\~

The only thing I try to fix this issue is to get the real path of the script file first, as showed on line 2 in the above code.

@thinreyxu that works for me. Thanks!

Was this page helpful?
0 / 5 - 0 ratings