# @adorade/plugin-error 中文文档

规范地址：https://npmcn.com/package/%40adorade/plugin-error/

版本：2\.0\.1
npm 元数据更新时间：2024-09-30T15:37:55.515Z
中文译文更新时间：2026-11-05T22:02:57.290Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40adorade/plugin-error
原文对照：https://npmcn.com/package/%40adorade/plugin-error/?lang=original
项目主页：https://github.com/adorade/plugin-error#readme
源码仓库：https://github.com/adorade/plugin-error

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：14.3 kB，5 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：1 个
- 首次发布：2024-02-15T13:01:17.405Z
- 最新版本发布：2024-09-30T15:37:55.369Z
- 近 30 天下载量：14221（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：3（近 12 个月 0 个）

## 中文简介

支持无害环境管理的 Gulp 插件处理出错

## 安装

```sh
npm install @adorade/plugin-error
```

也可以使用：`pnpm add @adorade/plugin-error`、`yarn add @adorade/plugin-error`、`bun add @adorade/plugin-error`

## README

# 插件错误

[![NPM version](https://img.shields.io/npm/v/@adorade/plugin-error?logo=npm)](https://www.npmjs.org/package/@adorade/plugin-error) [![GitHub package.json version](https://img.shields.io/github/package-json/v/adorade/plugin-error?color=green&logo=github)](https://github.com/adorade/plugin-error/blob/main/package.json) [![license](https://img.shields.io/github/license/adorade/plugin-error)](https://mit-license.org/) [![Depfu Status](https://img.shields.io/depfu/dependencies/github/adorade/plugin-error)](https://depfu.com/repos/github/adorade/plugin-error) [![GitHub Actions](https://github.com/adorade/plugin-error/workflows/Node%20CI/badge.svg)](https://github.com/adorade/plugin-error/actions) [![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen)](https://renovatebot.com/)

> 支持无害环境管理的Gulp插件处理出错 .

这套是纯粹的无害环境管理。 请 [读取此](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)。 。 。 .

## 安装

```bash
npm install @adorade/plugin-error --save-dev
# Or with yarn:
yarn add @adorade/plugin-error --dev
```

## 使用量

```js
import PluginError from '@adorade/plugin-error';

const err = new PluginError('test', {
  message: 'something broke',
});

const err = new PluginError({
  plugin: 'test',
  message: 'something broke',
});

const err = new PluginError('test', 'something broke');

const err = new PluginError('test', 'something broke', {
    showStack: true,      // false (default) | true
    showProperties: false // true (default) | false
});

const existingError = new Error('OMG');
const err = new PluginError('test', existingError, { showStack: true });
```

## API 密码

`new PluginError(plugin, message[, options])`

需要错误构建器 :

-   `plugin` - 一个 `String` 这应该是您的插件的模块名称
-   `message` - 一个 `String` 信件或已有的 `Error` 对象
-   `options` - 一个 `Object` 选项

**行为:**

-   默认不会显示堆栈 。 设定 `options.showStack` 如果您认为堆栈对您的错误很重要, 则改为真实 .
-   如果您通过一个错误对象作为信件, 堆栈将被从中拉出, 否则将创建一个 .
-   如果您在自定义堆栈字符串中通过, 您需要包含此消息 .
-   错误属性将包含在 `err.toString()`,但可通过添加 `{ showProperties: false }` 在选项中.

## 许可证

见 [麻省理工学院](https://npmcn.com/package/%40adorade/plugin-error/LICENSE) 许可证权利和限制.

## 常见问题

### @adorade/plugin-error 是什么？

支持无害环境管理的 Gulp 插件处理出错

### 如何安装 @adorade/plugin-error？

在项目目录运行 npm install @adorade/plugin-error，或使用 pnpm add / yarn add / bun add。

### @adorade/plugin-error 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @adorade/plugin-error 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @adorade/plugin-error 可以商用吗？

@adorade/plugin-error 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @adorade/plugin-error 的下载量有多少？

根据 npm 官方下载统计，@adorade/plugin-error 在 2026/10/05 – 2026/11/03 这 30 天内被下载 14,221 次，日均约 474 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @adorade/plugin-error 还在维护吗？

最新版本 2\.0\.1 发布于 2024/09/30（2 年前）；至今共发布 3 个版本，其中过去 12 个月发布了 0 个；首次发布于 2024/02/15。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

