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-paths-by-type

v2.0.18

Published

根據類型 Symbol 取得對應的路徑陣列(支援全域 npm/yarn 路徑) / Get corresponding path array based on type Symbol (supports global npm/yarn paths)

Readme

@yarn-tool/get-paths-by-type

根據類型 Symbol 取得對應的路徑陣列(支援全域 npm/yarn 路徑、當前目錄、主模組路徑)。 Get corresponding path array based on type Symbol (supports global npm/yarn paths, current directory, and main module path).

安裝 (Installation)

# 使用 yarn / Using yarn
yarn add @yarn-tool/get-paths-by-type

# 使用 yarn-tool / Using yarn-tool
yarn-tool add @yarn-tool/get-paths-by-type
# yt 是 yarn-tool 的別名 / yt is an alias for yarn-tool
yt add @yarn-tool/get-paths-by-type

# 使用 pnpm / Using pnpm
pnpm add @yarn-tool/get-paths-by-type

# 使用 npm / Using npm
npm install @yarn-tool/get-paths-by-type

使用範例 (Usage Example)

import getPathsByType, {
  SymbolCurrentDirectory,
  SymbolGlobal,
  SymbolGlobalNpm,
  SymbolGlobalYarn,
  SymbolModuleMain,
} from '@yarn-tool/get-paths-by-type';

// 取得全域 Yarn 套件目錄 / Get global Yarn package directory
const yarnPaths = getPathsByType(SymbolGlobalYarn);
console.log(yarnPaths); // ['/usr/local/share/.config/yarn/global/node_modules']

// 取得全域 Npm 套件目錄 / Get global Npm package directory
const npmPaths = getPathsByType(SymbolGlobalNpm);
console.log(npmPaths); // ['/usr/local/lib/node_modules']

// 取得所有全域路徑(Yarn + Npm)/ Get all global paths (Yarn + Npm)
const globalPaths = getPathsByType(SymbolGlobal);
console.log(globalPaths); // [yarn packages path, npm packages path]

// 取得當前工作目錄 / Get current working directory
const cwdPaths = getPathsByType(SymbolCurrentDirectory);
console.log(cwdPaths); // [process.cwd()]

// 取得當前目錄(指定路徑)/ Get current directory (specified path)
const customCwdPaths = getPathsByType(SymbolCurrentDirectory, '/custom/path');

// 取得主模組路徑 / Get main module path
const mainModulePaths = getPathsByType(SymbolModuleMain);

API

getPathsByType(valueType, cwd?)

根據類型 Symbol 取得對應的路徑陣列。

參數 (Parameters):

  • valueType - 路徑類型 Symbol / Path type Symbol
  • cwd - 工作目錄(選填,用於 SymbolCurrentDirectory)/ Working directory (optional, for SymbolCurrentDirectory)

返回 (Returns): string[] - 路徑陣列 / Path array

Symbol 類型 (Symbol Types)

| Symbol | 說明 / Description | |--------|-------------------| | SymbolCurrentDirectory | 當前工作目錄 / Current working directory | | SymbolGlobal | 全域 Yarn + Npm 套件目錄 / Global Yarn + Npm package directories | | SymbolGlobalNpm | 全域 Npm 套件目錄 / Global Npm package directory | | SymbolGlobalYarn | 全域 Yarn 套件目錄 / Global Yarn package directory | | SymbolModuleMain | 主模組的路徑 / Main module path |

License

ISC