Getting Grafana Plugins building under WSL

  • What Grafana version and what operating system are you using?
    10.2.0, but I’m trying to set up an environment to build a plugin.
    I don’t have any Grafana source downloaded.

  • What are you trying to achieve?
    Set up an environment under WSL so I cann build and test Grafana plugins on a Windows 10 system, using VSCODE as my IDE.

  • How are you trying to achieve it?

  1. Started following the instructions here: Get started | Grafana Plugin Tools
  2. Had to upgrade to WSL 2 and upgrade my ubuntu distribution.
  3. Installed various packages from the guides.
  4. Generated an npm plugin and it looked ok.
  5. Installed vscode for WSL. That went ok.
  6. Looked at the plugin inside vscode and a lot of dependencies were being flagged as errors - things like @grafana/data.
  7. VSCODE for WSL seems to need yarn.
  8. Upgrade yarn - the npm gave a very old version that didn’t support dlx, for example.
  9. Followed the instuctions here: How to Install Yarn on Ubuntu {With Screenshots} | phoenixNAP KB
  10. Added the yarn vscode support.
  11. Still didn’t fix the problem.
  12. Tried building the npm version to confirm the @grafana stuff was there - and it failed with an error about webpack being missing.
  13. Trying to run yarn in the plugin directory gave an error about it being an npm plugin.
  14. Delete the npm plugin.
  15. Try and create a new yarn plugin - and it fails…
  • What happened?
    The creation of the yarn plugin failed:
$ yarn create @grafana/plugin
➤ YN0000: · Yarn 4.0.1
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @grafana/create-plugin@npm:2.6.0, @babel/runtime-corejs3@npm:7.23.2, and 292 more.
➤ YN0000: └ Completed in 9s 718ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 294 packages were added to the project (+ 25.66 MiB).
➤ YN0000: └ Completed in 2s 298ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ core-js-pure@npm:3.33.2 must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 1s 176ms
➤ YN0000: · Done with warnings in 13s 253ms

/tmp/xfs-18202ddf/dlx-3753/.pnp.cjs:8529
      Error.captureStackTrace(firstError);
            ^

Error: @grafana/create-plugin tried to access minimist, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: minimist
Required by: @grafana/create-plugin@npm:2.6.0 (via /tmp/xfs-18202ddf/dlx-3753/.yarn/cache/@grafana-create-plugin-npm-2.6.0-f2be29c5e9-2d879af670.zip/node_modules/@grafana/create-plugin/dist/bin/)

Require stack:
- /tmp/xfs-18202ddf/dlx-3753/.yarn/cache/@grafana-create-plugin-npm-2.6.0-f2be29c5e9-2d879af670.zip/node_modules/@grafana/create-plugin/dist/bin/run.js
    at require$$0.Module._resolveFilename (/tmp/xfs-18202ddf/dlx-3753/.pnp.cjs:8529:13)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at require$$0.Module._load (/tmp/xfs-18202ddf/dlx-3753/.pnp.cjs:8420:31)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/tmp/xfs-18202ddf/dlx-3753/.yarn/cache/@grafana-create-plugin-npm-2.6.0-f2be29c5e9-2d879af670.zip/node_modules/@grafana/create-plugin/dist/bin/run.js:7:34)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at require$$0.Module._extensions..js (/tmp/xfs-18202ddf/dlx-3753/.pnp.cjs:8572:33)
    at Module.load (node:internal/modules/cjs/loader:1091:32)

Node.js v20.9.0
  • What did you expect to happen?
    Follow the instructions, install the mountain of bits and I’d be able to compile the sample module and work with it in vscode. At present it won’t create the yarn flavor of the sample plugin and the npm sample failed to build - something about webpack missing - before I trashed it.

  • Can you copy/paste the configuration(s) that you are having problems with?
    Most of the versions are listed above, I can supply any others you need.

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No.

  • Did you follow any online instructions? If so, what is the URL?
    See above.