I am just exploring a way in order to open the default browser from Visual Studio Code API used for developing extensions.
Following is my code :
var disposable = vscode.commands.registerCommand('extension.browser', () => {
// The code you place here will be executed every time your command is executed
vscode.Uri.call("http://facebook.com");
});
How to open Browser URL from API using vscode class.
You don't need to install an external dependency. Opening an URL can be simply done with just the Node.js libraries and system commands. For e.g. use the child_process.exec to open an URL.
Declare a function like so:
and then call it from your code
There is no need for node or external libraries.
If you are using VS Code 1.31+, use the
vscode.env.open
function:For older VS Code versions, use the
vscode.open
command:Both of these will open the page in the user's default browser
I had to use npm open url in order to open in browser.