Panel Plugin Create Error

I encountered an error after following the tutorial instructions in step 3 for creating panel plugins:


[root@ip-10-56-250-233 20200612 18:37:40 grafana-plugins]# npx @grafana/toolkit plugin:create my-plugin
internal/modules/cjs/loader.js:1032
throw err;
^

Error: Cannot find module '/root/.npm/_npx/1554/lib/node_modules/@grafana/toolkit/node_modules/node-sass/scripts/install.js ’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
at Function.Module._load (internal/modules/cjs/loader.js:898:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: ‘MODULE_NOT_FOUND’,
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.14.1 install: node scripts/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.14.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-06-12T18_41_43_413Z-debug.log
Install for [ ‘@grafana/toolkit@latest’ ] failed with code 1

I installed Node.js (14.4.0), npm (6.14.5) and yarn (1.22.4) with the following commands:

curl -sL https://rpm.nodesource.com/setup_14.x | bash -
yum install -y nodejs
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
yum install yarn

Steps 1 and 2 in tutorial were completed, with grafana-plugins folder created inside /etc/grafana followed by command ‘chown root:grafana grafana-plugins’.

Same issue observed in this post:

You can use this plugin — https://github.com/grafana/simple-react-panel
It seems like it is suitable for working with tutorials ( https://grafana.com/tutorials/build-a-panel-plugin/#5 ).

The description of the plugin says which commands you need to run after installing the plugin. But there is an important nuance. Before command

yarn build

need to run:

npm install

Otherwise panel shows errors “Error loading: myorgid-simple-panel”

Ok, thanks for the response. I will try that plugin and post the outcome later.

Can you provide additional instructions for installing the simple-react-panel plugin? I am a bit lost in terms of the file/folder structure that would normally be found in the plugin directory, i.e. my-plugin, after running plugin:create. Just need to know what the plugin directory should be called, and what files from your github link need to be copied there prior to running yarn commands.

I work on Debian. Plugins are located in the folder “/var/lib/grafana/plugins”.
There you need to upload all the files using the link from GitHub ( https://github.com/grafana/simple-react-panel ). This is the plugin template “simple-react-panel”.
This is what I did instead of running the command “npx @grafana/toolkit plugin:create my-plugin”.
Initially, the folder is called “simple-react-panel-master”. After running the commands

yarn install
npm install
yarn build

The folder will be called “simple-react-panel”
Further - all according to the instructions.

Copied everything from git link to folder simple-react-panel-will. I got the following with ‘yarn install’ where proxy values are hidden purposely:

yarn install v1.22.4
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.1.3: The platform "linux" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning "@grafana/toolkit > @grafana/eslint-config@1.0.0-rc1" has incorrect peer dependency "eslint-plugin-jsdoc@^21.0.                                                 0".
warning "@grafana/toolkit > @grafana/ui > storybook-dark-mode@0.4.0" has unmet peer dependency "@storybook/api@>= 5.x".
warning "@grafana/toolkit > @grafana/ui > storybook-dark-mode@0.4.0" has unmet peer dependency "@storybook/addons@>= 5.                                                 x".
warning "@grafana/toolkit > @grafana/ui > storybook-dark-mode@0.4.0" has unmet peer dependency "@storybook/components@>                                                 = 5.x".
warning "@grafana/toolkit > @grafana/ui > storybook-dark-mode@0.4.0" has unmet peer dependency "@storybook/core-events@                                                 >= 5.x".
warning "@grafana/toolkit > @grafana/ui > storybook-dark-mode@0.4.0" has unmet peer dependency "@storybook/theming@>= 5                                                 .x".
warning "@grafana/toolkit > @grafana/ui > @grafana/slate-react > slate-react-placeholder@0.2.9" has unmet peer dependen                                                 cy "slate-react@>=0.22.0".
[5/5] Building fresh packages...
[-/3] ⡀ waiting...
[2/3] ⡀ node-sass
error /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/node-sass
Output:
Building: /usr/bin/node /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/usr/bin/node',
gyp verb cli   '/etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@12.18.1 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import sys; print "2.6.9
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node version: 12.18.1
gyp verb command install [ '12.18.1' ]
gyp verb install input version string "12.18.1"
gyp verb install installing version: 12.18.1
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 12.18.1
gyp verb ensuring nodedir is created /root/.node-gyp/12.18.1
gyp verb created nodedir /root/.node-gyp/12.18.1
gyp http GET https://nodejs.org/download/release/v12.18.1/node-v12.18.1-headers.tar.gz
gyp verb download using proxy url: "http://proxy.X.com:X/"
gyp WARN install got an error, rolling back install
gyp verb command remove [ '12.18.1' ]
gyp verb remove using node-gyp dir: /root/.node-gyp
gyp verb remove removing target version: 12.18.1
gyp verb remove removing development files for version: 12.18.1
gyp ERR! configure error
gyp ERR! stack Error: tunneling socket could not be established, statusCode=403
gyp ERR! stack     at ClientRequest.onConnect (/etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/tunnel-agent/index.js:166:19)
gyp ERR! stack     at Object.onceWrapper (events.js:422:26)
gyp ERR! stack     at ClientRequest.emit (events.js:315:20)
gyp ERR! stack     at Socket.socketOnData (_http_client.js:503:11)
gyp ERR! stack     at Socket.emit (events.js:315:20)
gyp ERR! stack     at addChunk (_stream_readable.js:295:12)
gyp ERR! stack     at readableAddChunk (_stream_readable.js:271:9)
gyp ERR! stack     at Socket.Readable.push (_stream_readable.js:212:10)
gyp ERR! stack     at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
gyp ERR! System Linux 4.14.165-103.209.amzn1.x86_64
gyp ERR! command "/usr/bin/node" "/etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/node-sass
gyp ERR! node -v v12.18.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

Then got this result for ‘npm install’:

npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated core-js@1.2.7: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated @types/jest-diff@24.3.0: This is a stub types definition. jest-diff provides its own type definitions, so you do not need this installed.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated left-pad@1.3.0: use String.prototype.padStart()
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN rm not removing /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/.bin/uglifyjs as it wasn't installed by /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/uglify-js
npm WARN rm not removing /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/.bin/jest as it wasn't installed by /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/jest
npm WARN rm not removing /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/.bin/rimraf as it wasn't installed by /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/rimraf
npm WARN rm not removing /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/.bin/semver as it wasn't installed by /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/semver
npm WARN rm not removing /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/.bin/mkdirp as it wasn't installed by /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/mkdirp
npm WARN rm not removing /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/.bin/json5 as it wasn't installed by /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/json5
npm WARN rm not removing /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/.bin/mime as it wasn't installed by /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/mime

> node-sass@4.14.1 install /etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/node-sass
> node scripts/install.js

internal/modules/cjs/loader.js:969
  throw err;
  ^

Error: Cannot find module '/etc/grafana/grafana-plugins/simple-react-panel-will/node_modules/node-sass/scripts/install.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/react-dev-utils/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN notsup Unsupported engine for watchpack-chokidar2@2.0.0: wanted: {"node":"<8.10.0"} (current: {"node":"12.18.1","npm":"6.14.5"})
npm WARN notsup Not compatible with your version of node/npm: watchpack-chokidar2@2.0.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/watchpack/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN @grafana/eslint-config@1.0.0-rc1 requires a peer of eslint-plugin-jsdoc@^21.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN storybook-dark-mode@0.4.0 requires a peer of @storybook/api@>= 5.x but none is installed. You must install peer dependencies yourself.
npm WARN storybook-dark-mode@0.4.0 requires a peer of @storybook/addons@>= 5.x but none is installed. You must install peer dependencies yourself.
npm WARN storybook-dark-mode@0.4.0 requires a peer of @storybook/components@>= 5.x but none is installed. You must install peer dependencies yourself.
npm WARN storybook-dark-mode@0.4.0 requires a peer of @storybook/core-events@>= 5.x but none is installed. You must install peer dependencies yourself.
npm WARN storybook-dark-mode@0.4.0 requires a peer of @storybook/theming@>= 5.x but none is installed. You must install peer dependencies yourself.
npm WARN slate-react-placeholder@0.2.9 requires a peer of slate-react@>=0.22.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.14.1 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.14.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-06-20T02_15_06_443Z-debug.log

Then this for ‘yarn build’:

yarn run v1.22.4
$ grafana-toolkit plugin:build
/bin/sh: grafana-toolkit: command not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The commands I used to install Node.js/npm/yarn as root user (first command sudo bash) at /, on a machine running Amazon Linux, prior to copying the plugin from github, were the following:

export http_proxy=http://proxy.X.com:X
export https_proxy=http://proxy.X.com:X
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
yum install -y nodejs
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
yum install yarn

Buddy, I don’t know what your problem is … I have never encountered such a thing.
It’s just that my friend and I are doing grafana at work. He did Linux, and I only as a programmer.

Ok, no problem, thanks for the suggestions.

Providing an update: The node-sass installation failure was due to a corporate proxy preventing the binary from downloading. Once that was resolved, I was able to install the simple react panel locally. However, after restarting grafana-server did not see the plugin listed in the console plugin list. I shared the results from that issue in a new post shown here if you had any thoughts:

Unfortunately the original npx command to create a plugin still has the same error with node-sass even with node-sass installed globally.

Got that. Thank you. I’ll mean.

Issue was resolved doing manual installation with plugins from the community. Required setting ownership permission recursively to the installed plugin folders, as well as making sure all instances in system that were running Grafana used same configuration for console.

Commands:

chown -R grafana:grafana /var/lib/grafana/plugins
chmod -R 700 /var/lib/grafana/plugins