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/yarnlock-error

v1.0.25

Published

factory for yarn.lock version detection errors

Readme

@yarn-tool/yarnlock-error

factory for yarn.lock version detection errors —— 為 yarn.lock 版本偵測 (Version Detection) 失敗提供統一錯誤 (Error) 的小型工廠套件:當內容無法判斷為 v1 或 berry(v2/v3)時,回傳具固定訊息的 TypeError,讓各套件對同一情況拋出一致的例外。

Features

  • newYarnLockParsedVersionError() 建立統一訊息的 TypeError
  • 支援自訂訊息,便於在呼叫端補上診斷資訊
  • 以預設匯出提供,import ... from 即可直接使用
  • 零相依(僅需 tslib),可安全被其他 yarn.lock 套件引用

Installation

yarn add @yarn-tool/yarnlock-error
yarn-tool add @yarn-tool/yarnlock-error
yt add @yarn-tool/yarnlock-error

Usage

import newYarnLockParsedVersionError from '@yarn-tool/yarnlock-error';

// 使用預設訊息:can't detect yarn.lock version
throw newYarnLockParsedVersionError();

// 自訂訊息以補上診斷資訊
throw newYarnLockParsedVersionError('current object not v1 yarnlock');

搭配版本判別使用:

import { newYarnLockParsedVersionError } from '@yarn-tool/yarnlock-error';

function assertKnownVersion(verType: number)
{
	if (verType === 0)
	{
		throw newYarnLockParsedVersionError();
	}
}

API Documentation

| 匯出 | 說明 | | --- | --- | | newYarnLockParsedVersionError(msg?) | 回傳 new TypeError(msg);未傳入 msg 時使用預設訊息 can't detect yarn.lock version,傳入 null / undefined 亦同(以 ?? 只替換空值) | | default | 同 newYarnLockParsedVersionError,便於直接 import 預設值 |

Configuration

本套件無設定檔或環境變數,唯一可調整項為函式參數:

| 參數 | 型別 | 預設值 | 說明 | | --- | --- | --- | --- | | msg | string? | can't detect yarn.lock version | 錯誤訊息;省略或為 null / undefined 時使用預設訊息 |

錯誤型別固定為 TypeError,呼叫端可直接以 catch (err) 後檢查 instanceof TypeError 處理。