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

@yarn-tool/get-global-dirs

v1.0.4

Published

獲取全局安裝目錄的工具,支援 npm、yarn 和 pnpm。Get global installation directories for npm, yarn, and pnpm.

Downloads

807

Readme

@yarn-tool/get-global-dirs

⚠️ 注意事項

此模組基於 sindresorhus/global-directory 並作為 CommonJS (CJS) 模組使用。

目前版本存在以下限制與已知問題(源自原版或環境差異):

  • pnpm YAML 支援缺失:原版模組尚未支援讀取 pnpm 的 YAML 格式配置(如 config.yaml),僅支援 rc 格式。
  • pnpm 套件路徑差異:在某些環境下,pnpm 的全局套件路徑可能位於 .../pnpm/store/5/node_modules 而非預設的 .../pnpm/global/5/node_modules
  • 暫無修復計畫:目前暫時不打算針對上述原版即存在的 bug 進行修正。

獲取全局安裝目錄的工具,支援 npm、yarn 和 pnpm。

Get global installation directories for npm, yarn, and pnpm.

功能特色

  • 多套件管理器支援: 自動偵測並解析 npm、yarn 和 pnpm 的全局目錄
  • 跨平台相容: 支援 Windows、macOS 和 Linux

安裝

yarn add @yarn-tool/get-global-dirs
yarn-tool add @yarn-tool/get-global-dirs
yt add @yarn-tool/get-global-dirs

使用方法

import globalDirectory from '@yarn-tool/get-global-dirs';

// 獲取 npm 全局目錄
console.log(globalDirectory.npm.prefix);
//=> '/usr/local'

console.log(globalDirectory.npm.packages);
//=> '/usr/local/lib/node_modules'

console.log(globalDirectory.npm.binaries);
//=> '/usr/local/bin'

// 獲取 yarn 全局目錄
console.log(globalDirectory.yarn.packages);
//=> '/Users/username/.config/yarn/global/node_modules'

// 獲取 pnpm 全局目錄
console.log(globalDirectory.pnpm.packages);
//=> '/Users/username/Library/pnpm/global/5/node_modules'

API

globalDirectory

返回一個物件,包含三個屬性:

npm: IGlobalDirectoryEntry

  • prefix: 全局前綴目錄(相當於 npm prefix --global
  • packages: 全局套件目錄(相當於 npm root --global
  • binaries: 全局二進位檔目錄(相當於 npm bin --global

yarn: IGlobalDirectoryEntry

  • prefix: Yarn 全局資料目錄
  • packages: Yarn 全局套件目錄
  • binaries: Yarn 全局二進位檔目錄

pnpm: IGlobalDirectoryEntry

  • prefix: pnpm 資料目錄
  • packages: pnpm 全局套件目錄
  • binaries: pnpm 全局二進位檔目錄