$ npm install open-file-managerCross-platform utility to open a file or directory in the system's default file manager (Finder, Explorer, Nautilus, etc.)
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
$ npm install --save open-file-manager
import { openFileManager } from "open-file-manager";
// or
import openFileManager from "open-file-manager";
Opens a file or directory in the system's default file manager.
export const openFileManager = async (dirname?: string): Promise<void>;
Basic usage:
// Open current directory
await openFileManager();
// Open specific directory
await openFileManager("/home/user/documents");
// Open file location (selects the file in the file manager)
await openFileManager("./package.json");
Parameters:
pathname (optional)
string'.' (current directory)Returns:
Promise<void>Platform behavior:
explorer.exe. When opening a file, it selects the file in Explorer.open -R to reveal the item in Finder.Error handling:
try {
await openFileManager("/path/to/file");
} catch (error) {
console.error("Failed to open file manager:", error.message);
}
# Open current directory
open-file-manager
# Open specific directory
open-file-manager /home/user/documents
# Open file location
open-file-manager ./package.json
# Show help
open-file-manager --help
# Show version
open-file-manager --version
import { openFileManager } from "open-file-manager";
await openFileManager("./dist");
// This will open the file manager and select/highlight the file
await openFileManager("./README.md");
{
"scripts": {
"open:dist": "open-file-manager ./dist",
"open:current": "open-file-manager"
}
}
import { openFileManager } from "open-file-manager";
import path from "node:path";
// Works on Windows, macOS, and Linux
await openFileManager('/path/to/dir');
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Jon Schlinkert
Copyright © 2025, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.8.0, on May 25, 2025.