# New plugin architecture: How to build?

**URL:** <https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036>\
**Category:** Kibana\
**Tags:** kibana-plugin-development\
**Created:** [October 22, 2020, 3:50pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036 "2020-10-22T15:50:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dasko](https://avatars.discourse-cdn.com/v4/letter/d/958977/32.png) [@Dasko](https://discuss.elastic.co/u/Dasko)\
**Post date:** [October 22, 2020, 3:50pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/1 "2020-10-22T15:50:57Z")

</div>

Hello,

We are currently switching to Elasticsearch/Kibana 7.9.1 and creating new plugins, following the new architecture.

We were already using our own plugins before, and were building them via the build command of the plugin-helpers.

As the new plugins no longer use a package.json file, is it still possible de generate an archive/a binary? Is it possible to create a ZIP archive with all the files and distribute it as is?

I haven't found any information on that topic, sorry ☹

Cheers

---

<div class="post-metadata">

**Author:** ![rudolf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rudolf/32/51200_2.png) [@rudolf](https://discuss.elastic.co/u/rudolf)\
**Post date:** [October 29, 2020, 8:04pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/2 "2020-10-29T20:04:17Z")

</div>

Hi Dasko,

Our documentation is unfortunately still a bit scattered. To build a plugin distributable archive you can use the kibana plugin helpers (there's some documentation here: [https://github.com/elastic/kibana/tree/master/packages/kbn-plugin-helpers](https://github.com/elastic/kibana/tree/master/packages/kbn-plugin-helpers))

1. Create a plugin with a `kibana.json` file inside `kibana/plugins` i.e. `kibana/plugins/myplugin`
2. `cd kibana/plugins/myplugin`
3. run `node ../../scripts/plugin_helpers.js build`

Feel free to reach out if you have any problems...

---

<div class="post-metadata">

**Author:** ![16318a22907f3cbfa04b](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/16318a22907f3cbfa04b/32/36875_2.png) [@16318a22907f3cbfa04b](https://discuss.elastic.co/u/16318a22907f3cbfa04b)\
**Post date:** [November 15, 2020, 10:33pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/3 "2020-11-15T22:33:52Z")

</div>

Hi Rudolf,  
after build and install plugin for 7.9.1 Kibana don't start with error

```auto
FATAL Error: Cannot find module '/usr/share/kibana/plugins/my_plugin'

```

---

<div class="post-metadata">

**Author:** ![16318a22907f3cbfa04b](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/16318a22907f3cbfa04b/32/36875_2.png) [@16318a22907f3cbfa04b](https://discuss.elastic.co/u/16318a22907f3cbfa04b)\
**Post date:** [November 15, 2020, 11:20pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/4 "2020-11-15T23:20:20Z")

</div>

and no `index.js` file in `/usr/share/kibana/plugins/my_plugin` and in `my_plugin.zip`

---

<div class="post-metadata">

**Author:** ![Mikhail\_Shustov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikhail_shustov/32/49186_2.png) [@Mikhail\_Shustov](https://discuss.elastic.co/u/Mikhail_Shustov)\
**Post date:** [November 16, 2020, 1:29pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/5 "2020-11-16T13:29:50Z")

</div>

@16318a22907f3cbfa04b It seems `plugin_helpers` build only legacy plugins in 7.9.  
1.Could you update Kibana to 7.10?  
2.Did you use `plugin-generator` to create `my_plugin` structure? If so, `yarn build` in `/plugins/my_plugin` will build a distributable version.  
3.`index.js` is not required in`/plugins/my_plugin` folder.

---

<div class="post-metadata">

**Author:** ![16318a22907f3cbfa04b](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/16318a22907f3cbfa04b/32/36875_2.png) [@16318a22907f3cbfa04b](https://discuss.elastic.co/u/16318a22907f3cbfa04b)\
**Post date:** [November 16, 2020, 3:32pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/6 "2020-11-16T15:32:04Z")

</div>

1. I need plugin for 7.9.1
2. Yes, I use plugin-generator
3. I must use some dependency. Plugin-generator don't create package.json. So I had to create it manually. It looks like this

```auto
{
  "name": "my_plugin",
  "version": "1.0.0",
  "kibana": {
    "version": "7.9.1",
    "templateVersion": "1.0.0"
  },
  "license": "Apache-2.0",
  "scripts": {
    "kbn": "node ../../scripts/kbn.js",
    "build": "plugin-helpers build",
    "start": "node ../../scripts/kibana --dev",
    "lint:es": "node ../../scripts/eslint",
    "lint:sass": "node ../../scripts/sasslint",
    "lint": "yarn run lint:es && yarn run lint:sass"
  },
  "devDependencies": {
    "@kbn/plugin-helpers": "link:../../packages/kbn-plugin-helpers"
  },
  "dependencies": {
    "@hapi/joi": "^17.1.1",
    "@types/hapi__joi": "^17.1.6",
    "pg": "^8.4.2",
    "typescript": "^4.0.5"
  }
}

```

file `.kibana-plugin-helpers.json` look like this

```auto
{
  "buildSourcePatterns": [
    "package.json",
    "yarn.lock",
    "tsconfig.json",
    "{public,server}/**/*",
    "kibana.json"
  ]
}

```

`kibana.json` as created by plugin-generator

```auto
{
  "id": "myPlugin",
  "version": "7.9.1",
  "server": true,
  "ui": true,
  "requiredPlugins": ["navigation"],
  "optionalPlugins": []
}

```

Now `yarn build` create plugin zip and I can install plugin. Kibana starts with plugin. I see it in the list on the console (cli) when kibana starts. Now no errors. But kibana don't work, I see red banner when connect to http.  
With yarn start --oss everything work fine.  
Maybe someone has an example of how to build a plugin with dependencies

---

<div class="post-metadata">

**Author:** ![Mikhail\_Shustov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikhail_shustov/32/49186_2.png) [@Mikhail\_Shustov](https://discuss.elastic.co/u/Mikhail_Shustov)\
**Post date:** [November 16, 2020, 4:38pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/7 "2020-11-16T16:38:16Z")

</div>

as it seems from `kibana.json` manifest file

```auto
{
  "id": "myPlugin",
  "version": "7.9.1",
  "server": true,
  "ui": true,
  "requiredPlugins": ["navigation"],
  "optionalPlugins": []
}

```

you are trying to build Kibana Platform plugin, but unfortunately `plugin_helpers` build only Legacy plugins in 7.9. You have to use this workaround [https://github.com/elastic/kibana/issues/82466](https://github.com/elastic/kibana/issues/82466) or migrate Kibana to 7.10 where this problem has been fixed.

---

<div class="post-metadata">

**Author:** ![16318a22907f3cbfa04b](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/16318a22907f3cbfa04b/32/36875_2.png) [@16318a22907f3cbfa04b](https://discuss.elastic.co/u/16318a22907f3cbfa04b)\
**Post date:** [November 16, 2020, 5:08pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/8 "2020-11-16T17:08:25Z")

</div>

As I understand from what I read, the Kibana Platform plugin cannot use any additional nodejs modules. Is this correct? If this is incorrect, how and where should I specify dependencies?

---

<div class="post-metadata">

**Author:** ![Mikhail\_Shustov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikhail_shustov/32/49186_2.png) [@Mikhail\_Shustov](https://discuss.elastic.co/u/Mikhail_Shustov)\
**Post date:** [November 16, 2020, 5:15pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/9 "2020-11-16T17:15:35Z")

</div>

> [@16318a22907f3cbfa04b](#):
>
> As I understand from what I read, the Kibana Platform plugin cannot use any additional nodejs modules. Is this correct?

no, you are fine to use any modules. make sure you declared deps in your `package.json` and run `yarn kbn bootstrap`

---

<div class="post-metadata">

**Author:** ![16318a22907f3cbfa04b](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/16318a22907f3cbfa04b/32/36875_2.png) [@16318a22907f3cbfa04b](https://discuss.elastic.co/u/16318a22907f3cbfa04b)\
**Post date:** [November 16, 2020, 6:25pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/10 "2020-11-16T18:25:43Z")

</div>

I think I'm getting something wrong. If I can't use plugin-helpers, maybe I should do the build in some other way? Should I use `node scripts/build_kibana_platform_plugins --dist`? My plugin is made in a new format. What is the correct build sequence in this case?

---

<div class="post-metadata">

**Author:** ![16318a22907f3cbfa04b](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/16318a22907f3cbfa04b/32/36875_2.png) [@16318a22907f3cbfa04b](https://discuss.elastic.co/u/16318a22907f3cbfa04b)\
**Post date:** [November 16, 2020, 7:42pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/11 "2020-11-16T19:42:41Z")

</div>

> [@Custom Plugins 7.7.0](https://discuss.elastic.co/t/custom-plugins-7-7-0/240927):
>
> Hi, I'm having a hard time understanding a few things regarding custom plugin development since I cannot seem to find enough documentation about it: How do I build a single plugin without having to build the entire kibana? (e.g. the custom plugin that would reside in the '/plugins' folder which is the default folder that the cmd 'node scripts/generate-plugin defaults you to); How can I add a dependency specially for my plugin (this was possible back in 7.3.0)? Is it possible for someone to po…

All right. I Should have looked here. Now everything is working. I will only add that the plugin archive should be done on Linux. On a Windows machine it turns out to be incorrect and there will be an error during installation `Plugin installation was unsuccessful due to error "EACCES: permission denied, open '/usr/share/kibana/plugins/.plugin.installing/package.json'"`  
No more problems.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 14, 2020, 7:42pm UTC](https://discuss.elastic.co/t/new-plugin-architecture-how-to-build/253036/12 "2020-12-14T19:42:43Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
