Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-- Command Arguments Cannot Be Passed to Electron #3873

Open
3 tasks done
CongAn opened this issue Mar 8, 2025 · 0 comments
Open
3 tasks done

-- Command Arguments Cannot Be Passed to Electron #3873

CongAn opened this issue Mar 8, 2025 · 0 comments

Comments

@CongAn
Copy link

CongAn commented Mar 8, 2025

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Forge version

7.7.0

Electron version

v35.0.0

Operating system

Windows 11 24H2

Last known working Forge version

No response

Expected behavior

We encountered an issue when trying to pass arguments to electron using the command electron-forge start -- --remote-debugging-port=9222, which results in the error: error: unknown option '--remote-debugging-port=9222'.

After debugging, we discovered that the electron-forge command cannot handle the -- parameter separator correctly, which prevents electron from receiving the argument --remote-debugging-port=9222.

Image

Actual behavior

We added direct debug print statements in the command file:

node_modules/@electron-forge/cli/dist/electron-forge-start.js
(async () => {
    // ++++++++ debug print start ++++++++
    console.log('process.argv', process.argv);
    // ++++++++ debug print start ++++++++
    let commandArgs = process.argv;
    let appArgs;
    const doubleDashIndex = process.argv.indexOf('--');
    if (doubleDashIndex !== -1) {
        commandArgs = process.argv.slice(0, doubleDashIndex);
        appArgs = process.argv.slice(doubleDashIndex + 1);
    }
})();

Run of the command:

PS C:\Work\projects\my-electron-ts-vite-app> npx electron-forge start -- --remote-debugging-port=9222 
√ Checking your system
process.argv [
  'C:\\Users\\xxx\\AppData\\Local\\fnm_multishells\\95900_1741453597461\\node.exe',
  'C:\\Work\\projects\\my-electron-ts-vite-app\\node_modules\\@electron-forge\\cli\\dist\\electron-forge-start.js',
  '--remote-debugging-port=9222'
]
error: unknown option '--remote-debugging-port=9222'
PS C:\Work\projects\my-electron-ts-vite-app> npx electron-forge start --- --remote-debugging-port=9222
√ Checking your system
process.argv [
  'C:\\Users\\xxx\\AppData\\Local\\fnm_multishells\\95900_1741453597461\\node.exe',
  'C:\\Work\\projects\\my-electron-ts-vite-app\\node_modules\\@electron-forge\\cli\\dist\\electron-forge-start.js',
  '---',
  '--remote-debugging-port=9222'
]
error: unknown option '---'

The -- argument disappears during the parameter passing, but --- can be passed.

Steps to reproduce

npx electron-forge start --- --remote-debugging-port=9222

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant