Skip to content

Instantly share code, notes, and snippets.

@primaryobjects
Last active December 28, 2020 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save primaryobjects/fb357c3821fe70198b68e37b13a1fc12 to your computer and use it in GitHub Desktop.
Save primaryobjects/fb357c3821fe70198b68e37b13a1fc12 to your computer and use it in GitHub Desktop.
VSCode node.js launch config for automatically starting the web browser. Visual Studio Code, VS Code, launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/app.js",
"serverReadyAction": {
"pattern": "listening on port ([0-9]+)",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
@primaryobjects
Copy link
Author

This config allows the web browser to automatically open to the localhost url at the correct port, when debugging an app with node.js and express. It works via the regular expression pattern that checks for listening on port 3000 and then opening the web browser to the port number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment