Hello Everybody!
I am currently in the process of creating a new panel plugin by following the tutorial located here: Create Plugin and here Build your first plugin.
Steps I followed in accordance with the tutorial:
npm init @grafana/plugin
selected panel type, name, description and so on…
npm i
npm run dev
I got an error by npm run dev:
ERROR in ./module.ts
Module build failed (from ../node_modules/swc-loader/src/index.js):
Error: failed to handle: base_dir(./src) must be absolute. Please ensure that `jsc.baseUrl` is specified correctly.
webpack 5.88.2 compiled with 1 error in 330 ms
Type-checking in progress...
thread '<unnamed>' panicked at 'base_dir(./src) must be absolute. Please ensure that `jsc.baseUrl` is specified correctly.', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_transforms_module-0.173.28/src/path.rs:104:13
assets by status 17.1 KiB [cached] 6 assets
./module.ts 39 bytes [built] [1 error]
ERROR in ./module.ts
Module build failed (from ../node_modules/swc-loader/src/index.js):
Error: failed to handle: base_dir(./src) must be absolute. Please ensure that `jsc.baseUrl` is specified correctly.
Can someone provide assistance? I expected it to work smoothly since the instructions are directly from Grafana, and I am following the prescribed steps. Any help would be greatly appreciated!
Cheers,
Marcelo
Hi there @companymvms - this is due to a bug which was introduced in swc/core which was released yesterday. It has since been fixed, we’re just waiting for the new release.
For now, you’ll need to downgrade to the previous version "@swc/core": "1.3.75"
in your package.json
related issue: Bug: everything fresh installed, yarn build doesnt work. · Issue #344 · grafana/plugin-tools · GitHub
Thank you very much @davidharris . Which version exactly it is working? I tried 1.3.76 and 1.3.62 … I will try others here… It is a great tipp! 
No problem - 1.3.76 is latest which includes the bug, my post above recommends 1.3.75 which we’ve confirmed still works as expected 
Thank you very much @davidharris . Which version exactly it is working? I tried 1.3.76 and 1.3.62 and got the same error … I tried 1.3.0 and I got only this error now:
ERROR in ./module.ts
Module build failed (from ../node_modules/swc-loader/src/index.js):
Error: failed to handle: base_dir(./src) must be absolute. Please ensure that `jsc.baseUrl` is specified correctly.
Thanks and any advice would be great!
Have you remembered to re-run npm i
after changing the version in package.json
?
Hi @davidharris , thanks for your support!
Yes, I remember. I’m encountering the same error even with version 1.3.75. Additionally, I deleted the package-lock.json file and re-ran npm i just to be certain.
Afraid I can’t reproduce then
it works fine for me with 1.3.75.
2 options you could try:
1 Like
Hi @companymvms you need to set "@swc/core": "1.3.75"
(notice the removal of the ^ symbol) and run npm install
later to see this issue fixed. Or you can do it all in a single command without having to modify any file yourself by running npm install -E @swc/core@1.3.75
(notice -E to install the exact version)
If you keep the ^
it’ll keep installing the latest patch version even if you specify the specific patch version yourself.
For anyone looking to fix this problem:
A new version of create-plugin had been released that has 1.3.75 pinned as a dependency. Update to the latest create-plugin configuration:
npx @grafana/create-plugin@latest update
Note: make sure to select “Yes, all of them” when prompted Would you like to update the following dependencies in the package.json?
Then run npm install
to install the correct dependencies.
2 Likes
Thanks @davidharris . I created just a new project from scratch and it worked! Thanks
Thank you @academo! Good advice!!! I have just created a new project from scratch and it is now functioning.