Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Open closestNew to Visual Studio Code? Get it now.
Open closest

Open closest

Roman Decker

|
1 install
| (0) | Free
Open the closest package.json file to the currently open file
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Open closest

A VS Code extension that opens the closest package.json or barrel file to the currently open file.

Note: This extension was entirely AI-generated.

Features

  • Open closest package.json: Navigate up the directory hierarchy from your current file to find and open the nearest package.json file
  • Open closest barrel file: Find and open the nearest barrel file (index.ts, index.tsx, index.js, index.jsx, index.mdx, or custom)

Commands

  • Open closest package.json - Opens the closest package.json file to the active editor
  • Open closest barrel file - Opens the closest barrel file to the active editor

Access these commands via:

  • Command Palette: Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux) and search for the command name

Configuration

You can customize which files are considered "barrel files" by adding to your VS Code settings:

"openClosest.barrelFileNames": [
  "index.ts",
  "index.tsx",
  "index.js",
  "index.jsx",
  "index.mdx"
]

The extension will search for these files in the order specified.

How it works

When you run either command:

  1. The extension checks the current directory of the open file for matching files
  2. If not found, it checks the parent directory
  3. It continues moving up the directory tree until it finds a matching file
  4. The search stops at the workspace root boundary
  5. If a file is found, it opens in the editor
  6. If no file is found, an error message is displayed

Requirements

  • VS Code 1.95.0 or higher

Development

Building

npm run esbuild

Running the extension

  1. Press F5 to launch a VS Code Extension Development Host
  2. In the development window, open the command palette (Cmd+Shift+P / Ctrl+Shift+P)
  3. Run "Open closest package.json" or "Open closest barrel file"

Debugging

  • Set breakpoints in the code
  • Run the extension with F5
  • Use the VS Code debugger as normal

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft