grafana-starter-datasource
grafana-starter-datasource copied to clipboard
Error: [$injector:unpr] Unknown provider
Hi,
I'm running Grafana 7.4.2 locally.
I've built a data source plugin using grafana-starter-datasource. I pointed Grafana to its dist
folder.
Grafana's defaults.ini:
# Directory where grafana will automatically scan and look for plugins
plugins = C:\src\grafana-starter-datasource\dist
When I run yarn watch
, everything works fine.
However, when I run yarn build
(in order to build a plugin to install to remote Grafana server), my data source stops working:
FooBar Datasource plugin failed
Error: [$injector:unpr] Unknown provider: tProvider <- t http://errors.angularjs.org/1.6.9/$injector/unpr?p0=tProvider%20%3C-%20t
This seems to be because of minification.
Unminified (208 KB), result of yarn watch
- works:
Minified (39 KB), result of yarn build
- doesn't work:
I noticed this happening only recently.
My dependencies (package.json
):
{
"name": "simple-datasource",
"version": "1.0.0",
"description": "Grafana Data Source Plugin Template",
"scripts": {
"build": "grafana-toolkit plugin:build",
"test": "grafana-toolkit plugin:test",
"dev": "grafana-toolkit plugin:dev",
"watch": "grafana-toolkit plugin:dev --watch",
"sign": "grafana-toolkit plugin:sign"
},
"author": "Grafana Labs",
"license": "Apache-2.0",
"devDependencies": {
"@grafana/data": "7.4.2",
"@grafana/runtime": "7.4.2",
"@grafana/toolkit": "7.4.2",
"@grafana/ui": "7.4.2",
"@testing-library/jest-dom": "5.4.0",
"@testing-library/react": "^10.0.2",
"@types/lodash": "latest",
},
"dependencies": {
"grafana": "^1.0.1"
}
"engines": {
"node": ">=14"
}
}
@dkozar have you made any changes to the data source?
I tested with the latest version of the grafana-starter-datasource and yarn build
worked fine. This is my package.json - it does not have the dependencies section that you have:
{
"name": "simple-datasource",
"version": "1.0.0",
"description": "Grafana Data Source Plugin Template",
"scripts": {
"build": "grafana-toolkit plugin:build",
"test": "grafana-toolkit plugin:test",
"dev": "grafana-toolkit plugin:dev",
"watch": "grafana-toolkit plugin:dev --watch",
"sign": "grafana-toolkit plugin:sign",
"start": "yarn watch"
},
"author": "Grafana Labs",
"license": "Apache-2.0",
"devDependencies": {
"@grafana/data": "latest",
"@grafana/toolkit": "latest",
"@grafana/ui": "latest",
"@types/lodash": "latest",
"@testing-library/jest-dom": "5.4.0",
"@testing-library/react": "^10.0.2"
},
"engines": {
"node": ">=14"
}
}
Usually this error would occur for minified code if an @ngInject
annotation was missing for an Angular constructor. Example of a constructor: https://github.com/grafana/grafana/blob/main/public/app/plugins/datasource/postgres/query_ctrl.ts#L42
/** @ngInject */ constructor( $scope: any, $injector: auto.IInjectorService, private templateSrv: TemplateSrv, private uiSegmentSrv: any ) {
But the starter data source doesn't have any Angular constructors so it must be a dependency that is causing this.
Have you tried removing the node modules and doing a yarn install --pure-lockfile
?
Hi, @daniellee.
I tried both approaches, and it didn't help.
yarn install for some reason didn't work for me ("Couldn't find package "tslib" on the "npm" registry"), but I did npm install
without package-lock.json
and it's still the same.
As for the Angular - no Angular here, our plugin is a pure React plugin.
Here's the error message:
FooBar Datasource plugin failed
Error: [$injector:unpr] Unknown provider: tProvider <- t https://errors.angularjs.org/1.8.2/$injector/unpr?p0=tProvider%20%3C-%20t
There's nothing more specific in the console.
@dkozar can we book a session to have a look at this? I can't recreate this bug.
Which OS (Windows 10?) are you running on and which version of Node/npm?
@dkozar did you get this resolved?
No, that was never resolved. I was not able to figure out what causes it, since there is this "disconnect" between our plugin and Grafana, which hosts the plugin. I there a way to make Grafana print out more about the error to browser console?