# @grafana/create-plugin 中文文档

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

版本：9\.0\.3
npm 元数据更新时间：2026-11-11T12:04:50.281Z
中文译文更新时间：2026-11-17T01:44:36.567Z
软件包许可：Apache-2\.0

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

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

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

- 包体积（解压后）：1.6 MB，425 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- Node.js 要求：\>=22
- 运行依赖：15 个
- 首次发布：2022-09-08T09:58:21.314Z
- 最新版本发布：2026-11-11T12:04:49.800Z
- 近 30 天下载量：9953（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：1530（近 12 个月 355 个）

## 中文简介

轻松创建 Grafana 插件 .

## 安装

```sh
npm install @grafana/create-plugin
```

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

## README

# Grafana / 创建插件

轻松创建 Grafana 插件 .

**毒性**

-   [Grafana / 创建插件](https://npmcn.com/package/%40grafana/create-plugin/#readme-grafana--create-plugin)
    -   [创建新插件](https://npmcn.com/package/%40grafana/create-plugin/#readme-create-a-new-plugin)
        -   [快速概览](https://npmcn.com/package/%40grafana/create-plugin/#readme-quick-overview)
            -   [`npx`](https://npmcn.com/package/%40grafana/create-plugin/#readme-npx)
            -   [`npm`](https://npmcn.com/package/%40grafana/create-plugin/#readme-npm)
            -   [`pnpm`](https://npmcn.com/package/%40grafana/create-plugin/#readme-pnpm)
            -   [`yarn` (树莓)](https://npmcn.com/package/%40grafana/create-plugin/#readme-yarn-berry)
            -   [`yarn` (1.x) (中文(简体) )](https://npmcn.com/package/%40grafana/create-plugin/#readme-yarn-1x)
    -   [迁移您已有的插件](https://npmcn.com/package/%40grafana/create-plugin/#readme-migrate-your-existing-plugin)
    -   [更新您的插件构建配置](https://npmcn.com/package/%40grafana/create-plugin/#readme-update-your-plugin-build-config)
    -   [自定义或扩展基本配置](https://npmcn.com/package/%40grafana/create-plugin/#readme-customizing-or-extending-the-basic-configs)
    -   [添加到您已有的插件中](https://npmcn.com/package/%40grafana/create-plugin/#readme-add-provisioning-to-your-existing-plugin)
    -   [捐款](https://npmcn.com/package/%40grafana/create-plugin/#readme-contributing)

**链接**

-   [插件开发者 Docs](https://grafana.com/developers/plugin-tools)

**`@grafana/create-plugin`** 用于Linux(WSL)的macOS,Linux和Windows子系统的工作.  
如果有什么不起作用,请 [提交问题](https://github.com/grafana/plugin-tools/issues/new)。 。 。 .  
如果你有问题或需要帮助,请问 [GitHub 讨论](https://github.com/grafana/plugin-tools/discussions)。 。 。 .

## 创建新插件

### 快速概览

在要存储您的插件的文件夹中运行命令 。 新插件将在您运行此命令的文件夹的子目录中被脚手架 .

创建插件可以与国家预防机制、PNPM或Yarn 1一起使用。 插件将被脚手架以使用您喜欢的软件包管理器 。 用您选择的软件包管理器运行命令 :

#### [`npx`](https://github.com/npm/npx)

```bash
npx @grafana/create-plugin@latest
```

#### [`npm`](https://docs.npmjs.com/cli/v7/commands/npm-init)

```bash
npm init @grafana/plugin
```

#### [`pnpm`](https://pnpm.io/cli/dlx)

```bash
pnpm dlx @grafana/create-plugin@latest
```

#### [`yarn`](https://yarnpkg.com/getting-started) (树莓)

```bash
yarn dlx @grafana/create-plugin@latest
```

#### [`yarn`](https://classic.yarnpkg.com/en/docs/getting-started) (1.x) (中文(简体) )

```bash
yarn create @grafana/plugin
```

* * *

## 迁移您已有的插件

警告:我们 [不支持](https://grafana.com/docs/grafana/latest/developers/angular_deprecation/) 写入的插件 `angular`

如果您有先前使用此程序创建的现有插件 `@grafana/toolkit` 您可以使用 遵循命令将其迁移到新建工具 :

```bash
# Run this command from the root of your plugin
cd ./my-plugin

npx @grafana/create-plugin@latest migrate
```

更多信息见 [这里](https://grafana.com/developers/plugin-tools/migration-guides/migrate-from-toolkit)

* * *

## 更新您的插件构建配置

**以防您的插件被使用 `@grafana/toolkit` 在确保首先使用 `npx @grafana/create-plugin migrate`。 。 。 .**

随着Grafana新版本的出世,我们不断更新我们的插件构建工具,以便保持相容性,使其更能发挥作用. 为了接收这些修改,并确保您的插件与最新的 Grafana 版本兼容, 您可以使用 `update` 命令, 自动更新您的构建配置 :

```bash
# Run this command from the root of your plugin
cd ./my-plugin

npx @grafana/create-plugin@latest update
```

更多信息见 [这里](https://grafana.com/developers/plugin-tools/migration-guides/update-create-plugin-versions)

* * *

## 自定义或扩展基本配置

您可以阅读更多关于定制或扩展我们的基本配置 [文档](https://grafana.com/developers/plugin-tools/how-to-guides/extend-configurations)。 。 。 .

## 添加到您已有的插件中

您可以通过在您现有的插件中包含规定来精简插件审查过程, 使审查人员能够更有效地测试您的插件 .

```bash
# Run this command from the root of your plugin
cd ./my-plugin

npx @grafana/create-plugin@latest provisioning
```

更多信息见我们 [文档](https://grafana.com/developers/plugin-tools/publish-a-plugin/provide-test-environment)。 。 。 .

* * *

## 捐款

我们总是感激捐款! 见 [捐款额](https://npmcn.com/package/CONTRIBUTING.md) 更多信息.

## 常见问题

### @grafana/create-plugin 是什么？

轻松创建 Grafana 插件 \.

### 如何安装 @grafana/create-plugin？

在项目目录运行 npm install @grafana/create-plugin，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 create-plugin，可以用 npx create-plugin 直接运行。

### @grafana/create-plugin 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/grafana\_\_create-plugin 是否存在。

### @grafana/create-plugin 支持 ESM 还是 CommonJS？

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

### @grafana/create-plugin 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=22。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @grafana/create-plugin 可以商用吗？

@grafana/create-plugin 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @grafana/create-plugin 的下载量有多少？

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

### @grafana/create-plugin 还在维护吗？

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

