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!
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
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.
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.
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.