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

cross-dirs

v1.1.0

Published

Platform-specific user directory paths for Node.js and Bun - TypeScript port of dirs-rs

Readme

cross-dirs

Introduction

  • a tiny low-level library with a minimal API
  • that provides the platform-specific, user-accessible locations
  • for retrieving and storing configuration, cache and other data
  • on Linux, Windows (≥ Vista), macOS and other platforms
  • works with both Node.js and Bun

Inspired by dirs, the original Rust crate.

The library provides the location of these directories by leveraging the mechanisms defined by

Platforms

This library supports Linux, macOS and Windows. Other platforms are also supported; they use the Linux conventions.

Usage

Dependency

bun add cross-dirs    # Bun
npm install cross-dirs # npm

Example

Library run by user Alice:

import * as dirs from 'cross-dirs';

dirs.homeDir();
// Lin: "/home/alice"
// Win: "C:\\Users\\Alice"
// Mac: "/Users/Alice"

dirs.audioDir();
// Lin: "/home/alice/Music"
// Win: "C:\\Users\\Alice\\Music"
// Mac: "/Users/Alice/Music"

dirs.configDir();
// Lin: "/home/alice/.config"
// Win: "C:\\Users\\Alice\\AppData\\Roaming"
// Mac: "/Users/Alice/Library/Application Support"

dirs.executableDir();
// Lin: "/home/alice/.local/bin"
// Win: null
// Mac: null

Features

| Function | Linux | Windows | macOS | | --- | --- | --- | --- | | homeDir | $HOME | {FOLDERID_Profile} | $HOME | | cacheDir | $XDG_CACHE_HOME | {FOLDERID_LocalAppData} | $HOME/Library/Caches | | configDir | $XDG_CONFIG_HOME | {FOLDERID_RoamingAppData} | $HOME/Library/Application Support | | configLocalDir | $XDG_CONFIG_HOME | {FOLDERID_LocalAppData} | $HOME/Library/Application Support | | dataDir | $XDG_DATA_HOME | {FOLDERID_RoamingAppData} | $HOME/Library/Application Support | | dataLocalDir | $XDG_DATA_HOME | {FOLDERID_LocalAppData} | $HOME/Library/Application Support | | executableDir | $XDG_BIN_HOME | null | null | | preferenceDir | $XDG_CONFIG_HOME | {FOLDERID_LocalAppData} | $HOME/Library/Preferences | | runtimeDir | $XDG_RUNTIME_DIR | null | null | | stateDir | $XDG_STATE_HOME | null | null | | audioDir | XDG_MUSIC_DIR | {FOLDERID_Music} | $HOME/Music | | desktopDir | XDG_DESKTOP_DIR | {FOLDERID_Desktop} | $HOME/Desktop | | documentDir | XDG_DOCUMENTS_DIR | {FOLDERID_Documents} | $HOME/Documents | | downloadDir | XDG_DOWNLOAD_DIR | {FOLDERID_Downloads} | $HOME/Downloads | | fontDir | $XDG_DATA_HOME/fonts | null | $HOME/Library/Fonts | | pictureDir | XDG_PICTURES_DIR | {FOLDERID_Pictures} | $HOME/Pictures | | publicDir | XDG_PUBLICSHARE_DIR | {FOLDERID_Public} | $HOME/Public | | templateDir | XDG_TEMPLATES_DIR | {FOLDERID_Templates} | null | | videoDir | XDG_VIDEOS_DIR | {FOLDERID_Videos} | $HOME/Movies |

Differences from dirs-rs

This library uses environment variables to determine directory paths, while dirs-rs uses native APIs:

| Platform | dirs-rs | cross-dirs | | --- | --- | --- | | Windows | SHGetKnownFolderPath API | %APPDATA%, %LOCALAPPDATA%, %USERPROFILE% | | Linux | user-dirs.dirs file parsing | XDG environment variables | | macOS | Same | Same |

In practice, this means cross-dirs returns the same paths as dirs-rs for default configurations.

Related

  • dirs-rs – Rust library that inspired this project
  • directories-rs – higher-level library with app-specific paths

License

MIT