npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

native-folder-picker

v0.1.0

Published

Open the native folder picker from Node.js and get the absolute path. Windows for now, with no dependencies.

Readme

native-folder-picker

Open the native folder picker from Node.js and get the absolute path of the selected folder. It works on Windows for now.

Browsers never expose absolute paths, so a local-first app has to open the dialog from its own backend. This package does that part.

  • No dependencies and no native builds
  • Cancellable with an AbortSignal, and closes itself after a timeout
  • Keeps folder names in any language intact
  • One dialog at a time
  • Errors with a code you can check

Install

npm install native-folder-picker

Requirements

  • Node.js 22 or newer (the package is ESM only)
  • Windows, in a desktop session

| Platform | Status | | -------- | --------------------------- | | Windows | Supported | | macOS | Planned (UNSUPPORTED now) | | Linux | Planned (UNSUPPORTED now) |

Usage

import { pickFolder } from 'native-folder-picker';

const path = await pickFolder({ title: 'Select a project folder' });

if (path === null) {
  console.log('Cancelled');
} else {
  console.log(path);
}

API

pickFolder(options?): Promise<string | null>

Resolves with the absolute path, or null if the user cancels.

| Option | Type | Default | Description | | --------- | ------------- | ------------------- | ---------------------------------------------------------------------------------------------------- | | title | string | 'Select a folder' | Text shown in the dialog | | timeout | number | 300000 | How long it may stay open, in whole milliseconds. 0 waits forever, and the maximum is 2147483647 | | signal | AbortSignal | none | Closes the dialog when aborted |

Errors

If signal is aborted, the promise rejects with an error whose name is AbortError. Invalid options reject with a TypeError or RangeError. Everything else is a FolderPickerError with a code:

| Code | Meaning | Suggested HTTP status | | -------------- | ---------------------------------------------------------------- | --------------------- | | ALREADY_OPEN | Another picker is already open (see Limitations) | 409 | | TIMEOUT | The picker stayed open longer than timeout | 408 | | UNSUPPORTED | The operating system isn't supported | 501 | | FAILED | The picker couldn't be opened. Check cause | 500 |

Using it in a server

Close the dialog when the browser disconnects, and turn the error codes into HTTP statuses. For example, in NestJS:

import { Controller, HttpException, Post, Res } from '@nestjs/common';
import type { Response } from 'express';
import { FolderPickerError, pickFolder } from 'native-folder-picker';

const STATUS_BY_CODE = {
  ALREADY_OPEN: 409,
  TIMEOUT: 408,
  UNSUPPORTED: 501,
  FAILED: 500,
};

@Controller('projects')
export class ProjectsController {
  @Post('select-folder')
  async selectFolder(@Res({ passthrough: true }) response: Response) {
    const controller = new AbortController();
    response.once('close', () => controller.abort());

    try {
      return await pickFolder({ signal: controller.signal });
    } catch (error) {
      // The browser is gone, so nobody is waiting for the result.
      if (controller.signal.aborted) return null;

      if (error instanceof FolderPickerError) {
        throw new HttpException(error.message, STATUS_BY_CODE[error.code], {
          cause: error,
        });
      }

      throw error;
    }
  }
}

Security

This package opens the dialog. It doesn't protect your endpoint, so the app still has to:

  • Listen on 127.0.0.1 only
  • Require authentication, and check the Origin and Host headers
  • Validate every path it receives, because a client can send any path without using the dialog
  • Decide whether to accept network paths such as \\server\share, because the user can pick one

Don't take title or timeout from a request. A client could show a misleading message, or keep the dialog open so that nobody else can use it.

Limitations

  • The dialog opens on the machine running Node.js, so it doesn't work for a remote server, a container or a headless session.
  • The lock covers one loaded copy of the package. Two Node.js processes, or two installed versions, can each open a dialog.
  • Windows shows the classic tree dialog, not the modern one.

Development

pnpm install
pnpm build         # compile to dist
pnpm dev           # compile on every change
pnpm example       # open a real dialog
pnpm typecheck
pnpm lint
pnpm format:check
pnpm check         # the three above

License

MIT