Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
The 'open' npm package is a simple utility to open a file, URL, or executable in the default program associated with that file type on the user's operating system. It can be used to open resources in the default browser, editor, or any other program.
Open URLs in the default web browser
This feature allows you to open a URL in the user's default web browser.
const open = require('open');
open('https://www.example.com');
Open files in the default application
This feature allows you to open a file in the default application associated with its file type, such as a PDF in a PDF viewer.
const open = require('open');
open('path/to/file.pdf');
Open files with a specific application
This feature allows you to open a file with a specific application, bypassing the default application.
const open = require('open');
open('path/to/file.txt', {app: {name: 'notepad'}});
Open files with application and arguments
This feature allows you to open a file with a specific application and pass command-line arguments to the application.
const open = require('open');
open('path/to/file', {app: {name: 'app-name', arguments: ['--arg1', '--arg2']}});
The 'opn' package was the predecessor to 'open' and has since been deprecated in favor of 'open'. It offered similar functionality to open resources with the default application or a specified one.
While 'execa' is more of a process execution tool than a direct alternative to 'open', it can be used to achieve similar results by running system commands to open files or URLs with specific applications.
The 'start' package is another alternative that can open files or URLs using the default application. It is less feature-rich compared to 'open' and is specific to Windows.
Open a file or url in the user's preferred application.
var open = require("open");
open("http://www.google.com");
open
taks an optional argument specifying the program to be used to open the
file or URL.
open("http://www.google.com", "firefox");
npm install open
win32
uses start
darwin
uses open
xdg-open
script from freedesktop.orgThe same care should be taken when calling open as if you were calling child_process.exec directly. If it is an executable it will run in a new shell.
FAQs
Open stuff like URLs, files, executables. Cross-platform.
We found that open demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.