{"id":17319,"library":"openurl","title":"Open URLs via Operating System","description":"The `openurl` package provides a simple Node.js module to programmatically open URLs, `mailto:` links, or local files using the operating system's default applications. For instance, `http` links will open in the default web browser, and `mailto` links in the default email client. The package's current and final stable version is `1.1.1`, which was last published over 10 years ago in January 2016. Consequently, `openurl` is no longer actively maintained and does not receive updates, bug fixes, or new features. While it may still function for basic use cases in CommonJS environments, it lacks modern features like native ECMAScript Modules (ESM) support and may have unaddressed platform-specific issues. Developers are strongly encouraged to use actively maintained alternatives like the `open` package (by Sindre Sorhus) for better cross-platform compatibility, ESM support, and ongoing reliability.","status":"abandoned","version":"1.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/rauschma/openurl","tags":["javascript","desktop","browser"],"install":[{"cmd":"npm install openurl","lang":"bash","label":"npm"},{"cmd":"yarn add openurl","lang":"bash","label":"yarn"},{"cmd":"pnpm add openurl","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only. There is no named or default ESM export. Use `require()` to access the `open` method.","wrong":"import { open } from 'openurl';","symbol":"open","correct":"const openurl = require('openurl');\nopenurl.open('https://example.com');"},{"note":"The `mailto` function is available as a property of the module loaded via `require()`. It is not an ESM export.","wrong":"import { mailto } from 'openurl';","symbol":"mailto","correct":"const openurl = require('openurl');\nopenurl.mailto(['recipient@example.com'], { subject: 'Hello', body: 'This is a test' });"}],"quickstart":{"code":"const openurl = require('openurl');\n\n// Open a URL in the default web browser\nopenurl.open('https://www.google.com').then(() => {\n  console.log('Opened Google in browser.');\n}).catch(err => {\n  console.error('Failed to open URL:', err.message);\n});\n\n// Open a mailto link in the default email client with recipients, subject, and body\nopenurl.mailto(['john.doe@example.com', 'jane.smith@example.com'], {\n    subject: 'Important Inquiry',\n    body: 'Dear recipients,\\n\\nThis is an automatically generated email.\\n\\nRegards,\\nYour App'\n}).then(() => {\n  console.log('Opened mail client for email.');\n}).catch(err => {\n  console.error('Failed to open mailto link:', err.message);\n});\n\n// Example of opening a local file (path should be absolute for best results)\n// Note: This often opens a directory viewer on some OS if it's a directory path.\n// On macOS, it might open the directory in Finder. On Windows, in Explorer.\nconst filePath = process.platform === 'win32' ? 'C:\\\\Windows' : '/tmp';\nopenurl.open(filePath).then(() => {\n  console.log(`Opened file/directory: ${filePath}`);\n}).catch(err => {\n  console.error('Failed to open file/directory:', err.message);\n});","lang":"javascript","description":"This quickstart demonstrates how to open a web URL, compose an email using a mailto link with multiple recipients, subject, and body, and open a local file path using the operating system's default applications."},"warnings":[{"fix":"Migrate to actively maintained alternatives such as the `open` package (by Sindre Sorhus) for modern, cross-platform URL opening capabilities, including ESM support and continuous maintenance. For example, `npm install open` then `import open from 'open'; await open('https://example.com');`","message":"The `openurl` package is abandoned, with its last update over 10 years ago (v1.1.1, January 2016). It does not receive security updates, bug fixes, or compatibility improvements for newer operating systems or Node.js versions. Relying on this package in production is highly discouraged.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure your project uses CommonJS `require('openurl')` or convert your project to use dynamic `import()` for `openurl` if you must use it in an ESM context, though migration to a modern ESM-compatible library is recommended.","message":"This package is exclusively a CommonJS module and does not natively support ECMAScript Modules (ESM) `import` syntax. Attempting to `import openurl from 'openurl'` will result in an error in pure ESM environments.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Thoroughly test `openurl` functionality across all target operating systems and with various URL patterns. Due to its abandoned status, these issues are unlikely to be fixed. Prefer using a modern, actively maintained library that addresses such cross-platform nuances.","message":"The package may exhibit inconsistent behavior or outright failures on certain operating systems or with specific URL formats. For instance, GitHub issues mention problems opening URLs containing `=` on Windows and unexpected side effects like wiping Firefox settings on some systems.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure you are using `require()` for CommonJS: `const openurl = require('openurl'); openurl.open('...');` If in an ESM project, consider using dynamic `import()` or, preferably, migrate to an ESM-native package like `open`.","cause":"Attempting to use `openurl` with ESM `import` syntax or incorrect CommonJS usage.","error":"TypeError: openurl.open is not a function (or similar for mailto)"},{"fix":"Install `xdg-utils` which provides `xdg-open` on most Linux distributions (e.g., `sudo apt-get install xdg-utils` on Debian/Ubuntu, `sudo yum install xdg-utils` on Fedora/CentOS). Ensure your environment is configured to use graphical applications.","cause":"On Linux systems, `openurl` (or the underlying system command) relies on `xdg-open` which might not be installed or configured correctly, especially in minimal environments or WSL without proper desktop integration.","error":"Error: Command failed: xdg-open: not found"},{"fix":"There is no direct fix for this issue within `openurl` due to its abandonment. The recommended solution is to switch to a modern, actively maintained library like `open` (https://www.npmjs.com/package/open), which has better cross-platform handling for such edge cases.","cause":"A known, unresolved bug specific to `openurl` on Windows when the URL string contains an equals sign (`=`), causing the system to misinterpret it as a file path or command.","error":"URL with '=' does not open in Windows, opens explorer folder instead."}],"ecosystem":"npm","meta_description":null}