11

I'm trying to use the chrome.exe headless REPL, but it seems to immediately exit.

I'm currently on Windows 7 Pro 64-bit Chrome Version 72.0.3626.121

Command Used:

$ chrome.exe --headless --disable-gpu --enable-logging --no-sandbox --repl https://www.chromestatus.com/

Result

As you can see below it almost looks like I am able to start using the REPL, except there is no >>> .

$ [0307/131904.237:INFO:headless_shell.cc(370)] Type a Javascript expression to evaluate or "quit" to exit.


If i were to type a javascript expression:

$ [0307/132502.083:INFO:headless_shell.cc(370)] Type a Javascript expression to evaluate or "quit" to exit.
const someNumber = 1
'const' is not recognized as an internal or external command,
operable program or batch file.
$

It appears chrome has already exited. I've tried this in cmd.exe, PowerShell and ConEmu all with the same result. This is my first time with chrome headless so I apologize if the answer is obvious.

Kevin Brock
  • 131
  • 8

1 Answers1

-1

Chrome's official blog recommends two methods users can use to keep chromium from exiting after being launched from the command line. The blog explicitly and repeatedly mentions windows in their instructions so I assume they apply to the windows version of chrome as well:

  1. Start the browser with remote debugging enabled by passing --remote-debugging-port=PORTNUM at the command line, or
  2. Start chrome in REPL mode by passing --repl at the command line. This will cause chromium to persist as long as stdin remains open.

I've tested both approaches and can attest to both approaches working with Chromium 108.0.5359.124 on Linux as of the time of this writing. For the sake of completeness, I've included the exact commands I used to confirm this bellow:

  • Remote Debugging
    chromium --headless --temp-profile --password-store=basic --disable-gpu --remote-debugging-port=9222  https://example.com 
    
  • REPL Mode
    chromium --headless --temp-profile --password-store=basic --disable-gpu --remote-debugging-port=9222  https://example.com 
    
Tenders McChiken
  • 1,216
  • 13
  • 21