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 🙏

© 2025 – Pkg Stats / Ryan Hefner

system-icon2

v0.5.1

Published

Get associated file/folder icon

Downloads

587

Readme

system-icon2

An updated fork of system-icon.

Get associated file/folder icon for Node.js.

Installation

$ npm install --save system-icon2

For Electron Apps

If you're using this package in an Electron application, you need to rebuild it for Electron's Node.js version:

# Install electron-rebuild as a dev dependency
$ npm install --save-dev electron-rebuild

# Rebuild native modules for Electron
$ npx electron-rebuild

Or add this to your package.json scripts:

{
  "scripts": {
    "postinstall": "electron-rebuild"
  }
}

Alternatively, if using pnpm:

$ pnpm install --save-dev electron-rebuild
$ pnpm exec electron-rebuild

Supported platforms

  • macOS 10.6 or later
  • Windows Vista or later

Usage

Get icon for file or folder path:

const {writeFileSync} = require('fs');
const {
  getIconForPath,
  ICON_SIZE_MEDIUM
} = require('system-icon2');

getIconForPath("/path/to/file_or_folder", ICON_SIZE_MEDIUM, (err, result) => {
  if (err) {
    console.error(err);
  } else {
    writeFileSync("icon.png", result);
  }
});

Get icon for file extension:

const {writeFileSync} = require('fs');
const {
  getIconForExtension,
  ICON_SIZE_MEDIUM
} = require('system-icon2');

getIconForExtension(".ext", ICON_SIZE_MEDIUM, (err, result) => {
  if (err) {
    console.error(err);
  } else {
    writeFileSync("icon.png", result);
  }
});

API

Constants

Size constants

The correspondence between the size constants and the icon size actually obtainable on each platform is as follows:

| Constant | Windows | macOS | | ----------------------- | ------- | ------- | | ICON_SIZE_EXTRA_SMALL | 16x16 | 16x16 | | ICON_SIZE_SMALL | 32x32 | 32x32 | | ICON_SIZE_MEDIUM | 64x64 | 64x64 | | ICON_SIZE_LARGE | 256x256 | 256x256 | | ICON_SIZE_EXTRA_LARGE | 256x256 | 512x512 |

Functions

getIconForPath(path, size, callback)

Gets associated icon for file or folder path, and returns it in the PNG format.

getIconForExtension(extension, size, callback)

Gets associated icon for file extension, and returns it in the PNG format.

Troubleshooting

Electron: "was compiled against a different Node.js version"

If you see an error like:

The module was compiled against a different Node.js version using
NODE_MODULE_VERSION 127. This version of Node.js requires
NODE_MODULE_VERSION 140.

This happens because the native addon was compiled for regular Node.js, but Electron uses its own Node.js version. Solution:

  1. Install electron-rebuild:

    npm install --save-dev electron-rebuild
    # or
    pnpm install --save-dev electron-rebuild
  2. Rebuild the native modules for Electron:

    npx electron-rebuild
    # or
    pnpm exec electron-rebuild
  3. If the issue persists, try a clean rebuild:

    # Remove node_modules and rebuild
    rm -rf node_modules package-lock.json
    npm install
    npx electron-rebuild
    
    # For pnpm users
    rm -rf node_modules pnpm-lock.yaml
    pnpm install
    pnpm exec electron-rebuild
  4. You can also add electron-rebuild to your postinstall script:

    {
      "scripts": {
        "postinstall": "electron-rebuild"
      }
    }

Electron: "non context-aware native addons has been disabled"

This package is context-aware and should work with Electron. If you still see this error, ensure you're using the latest version (0.2.0+).

License

MIT