I was following the tutorial to build a custom datasource plugin and once I ran the command yarn dev it gave me the following error:
√ Linting
/ Bundling plugin in dev mode [tsl] ERROR in …\tutorial-plugin\src\ConfigEditor.tsx(2,10)
TS2305: Module ‘“…/tutorial-plugin/node_modules/@grafana/ui”’ has no exported member ‘LegacyForms’.
[tsl] ERROR in …\tutorial-plugin\src\QueryEditor.tsx(4,10)
TS2305: Module ‘“…/tutorial-plugin/node_modules/@grafana/ui”’ has no exported member ‘LegacyForms’.
ERROR in …\tutorial-plugin\src\ConfigEditor.tsx
./ConfigEditor.tsx
[tsl] ERROR in …\tutorial-plugin\src\ConfigEditor.tsx(2,10)
TS2305: Module ‘“…/tutorial-plugin/node_modules/@grafana/ui”’ has no exported member ‘LegacyForms’.
ERROR in …\tutorial-plugin\src\QueryEditor.tsx
./QueryEditor.tsx
[tsl] ERROR in …\tutorial-plugin\src\QueryEditor.tsx(4,10)
TS2305: Module ‘“…/tutorial-plugin/node_modules/@grafana/ui”’ has no exported member ‘LegacyForms’.
Trace: Build failed
at …\tutorial-plugin\node_modules@grafana\toolkit\src\cli\utils\useSpinner.js:24:29
at step (…\tutorial-plugin\node_modules@grafana\toolkit\node_modules\tslib\tslib.js:136:27)
at Object.throw (…\tutorial-plugin\node_modules@grafana\toolkit\node_modules\tslib\tslib.js:117:57)
at rejected (…\tutorial-plugin\node_modules@grafana\toolkit\node_modules\tslib\tslib.js:108:69)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
× Build failed
error Command failed with exit code 1.
info Visit yarn run | Yarn for documentation about this command.
Are you still getting the same error. The canary build is considered unstable, and we’ll make sure to update the tutorials with a stable version as soon as Grafana 7.0 has been released.
yarn run v1.22.4
$ grafana-toolkit plugin:dev
internal/validators.js:117
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at validateString (internal/validators.js:117:11)
at Object.basename (path.js:671:5)
at isLinkedMode (...\my-plugin\node_modules\@grafana\toolkit\bin\grafana-toolkit.js:13:12)
at entrypoint (...\my-plugin\node_modules\@grafana\toolkit\bin\grafana-toolkit.js:29:7)
at Object.<anonymous> (...\my-plugin\node_modules\@grafana\toolkit\bin\grafana-toolkit.js:51:9)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
code: 'ERR_INVALID_ARG_TYPE'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The path in tsconfig.json should indeed be ./node_modules/@grafana/toolkit/src/config/tsconfig.plugin.json. I’ve updated the data source template to reflect this.
@ivansantos Can you try running the npx command again, and see if this solves your problem?
I’ve ran yarn update and after that yarn dev. Here’s the error log:
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/diffLines.d.ts
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/diffLines.d.ts(8,13):
TS1005: '=' expected.
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/diffLines.d.ts
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/diffLines.d.ts(8,34):
TS1005: ';' expected.
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts(10,13):
TS1005: '=' expected.
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts(10,34):
TS1005: ';' expected.
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts(11,1):
TS1128: Declaration or statement expected.
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts(11,13):
TS1005: ';' expected.
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts(11,52):
TS1005: ';' expected.
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/printDiffs.d.ts
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/printDiffs.d.ts(8,13):
TS1005: '=' expected.
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/printDiffs.d.ts
ERROR in C:/Users/Aga/go/src/github.com/grafana/grafana/node_modules/@types/jest/node_modules/jest-diff/build/printDiffs.d.ts(8,57):
TS1005: ';' expected.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I tried running the npx command and got the same result as before:
PS E:\Work\my-plugin> yarn dev
yarn run v1.22.4
$ grafana-toolkit plugin:dev
internal/validators.js:117
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at validateString (internal/validators.js:117:11)
at Object.basename (path.js:671:5)
at isLinkedMode (E:\Work\my-plugin\node_modules\@grafana\toolkit\bin\grafana-toolkit.js:13:12)
at entrypoint (E:\Work\my-plugin\node_modules\@grafana\toolkit\bin\grafana-toolkit.js:29:7)
at Object.<anonymous> (E:\Work\my-plugin\node_modules\@grafana\toolkit\bin\grafana-toolkit.js:51:9)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
code: 'ERR_INVALID_ARG_TYPE'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Edit: I just tried to run yarn dev in the git bash and the code built successfully. It seems that the problem is related to Powershell and Windows command line