Compiling typescript of a plugin in Linux throws error in grafana toolkit (8.3.4 or 9.3.6)

Hi Grafana Experts,
We are migrating our solution from windows to dockers, so, we are migrating our builds from Windows to Linux.
We have a a plugin that is a DataSource, with a backend (go) and frontend (react and typescript).
The build process of the backend went smoothly, we used an image with go, placed the code on the right place we run the compilation command and a plugin back end is born.
Now, we are working with the frontend and in windows we got no errors:

With the same code on Linux, we have several linting problems that we skipped to be able to reach the build phase and on the build phase we got the following errors:

âś– Cannot read property 'name' of null
  Trace: TypeError: Cannot read property 'name' of null
      at /node_modules/@grafana/toolkit/src/config/webpack.plugin.config.js:61:21
      at Array.forEach (<anonymous>)
      at /node_modules/@grafana/toolkit/src/config/webpack.plugin.config.js:58:13
      at Generator.next (<anonymous>)
      at fulfilled (/node_modules/@grafana/toolkit/node_modules/tslib/tslib.js:115:62)
      at /node_modules/@grafana/toolkit/src/cli/utils/useSpinner.js:20:21
      at Generator.throw (<anonymous>)
      at rejected (/node_modules/@grafana/toolkit/node_modules/tslib/tslib.js:116:69)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

We are using the following version:

yarn run v1.22.17
Node.js v14.19.1
grafana/toolkit v9.3.6 and 8.3.4 (we tried with both toolkits - we deleted the node_modules on each switch followed by yarn install, 9.3.6 gives out less linting errors)
Typescript was changed to 3.9.4 using: npm install typescript@3.9.4 (the previous version for typescript was 4.4.0 and we had a warning that it might cause some problems)

I’ve tried many things during the last 2 days and I’m stuck at this moment. Any gentle soul can help me out?

Thanks,
LP

Hi @lpinho it is hard to tell without seeing the code itself. My best guess is that there’s something wrong in the file system and toolkit is not getting the cwd correctly.

What I can advice you, now that you are doing migration work is to move from @grafana/toolkit and start using @grafana/create-plugin. You can find a guide to migrate from toolkit to create-plugin here plugin-tools/README.md at main · grafana/plugin-tools · GitHub

Hi grafanad404,
Thanks for your reply.
The current versions are already certified by the company QA team, so, to migrate its a lengthy process, so it would be great if we could make this work using the current toolset.

The code that is returning the error is from the toolkit, not from our code, so we don’t know what the code does.
Yesterday, I made yet another test, I used an ubuntu 20.04 wsl installation of ubuntu and I was able to compile the same code.

Then, I used an image based on Ubuntu and did the same steps to setup the environment and the error is the the same has before.

As you can see, the toolset is the same:

The error is occurring here (/node_modules/@grafana/toolkit/src/config/webpack.plugin.config.js):

Unfortunately I cannot wait for the QA team :(, hopping you guys can help me out.

Thanks,
LP

Yes I followed the code from your first post which is what tells me that there’s something wrong in the file system. This code uses process.cwd to get your current plugin path and find all the module.js files inside. It seems that it is not working.

My best advice without access to the source code myself is to try to debug the toolkit error and see why it is not finding the module.js in your specific case or use the image of ubuntu that works for your case.

We haven’t seen a problem like this before in the toolkit so I am guessing this is a specific problem to your migration process.

As as side note, coming from windows to linux, maybe there’s something wrong in the file names because of encoding? worth to check.

You are right :slight_smile:
Its not a problem with the file system, its a problem how I was using the file system.
My mistake, I didn’t defined the workdir for this image, so, when I copied the source code from the host to the image, it was writing everything on the root (/) of the file system.
So, after changing the Dockerfile to set the workdir, it compiled successfully.

Thanks for your support,
Grafanad404

1 Like

I’m glad to hear you solved the problem.

Indeed when I said “problem with the file system” I meant that the files were in the wrong folder or with the wrong names.

My advice to migrate to create-plugin still stands as we will remove support from it in Grafana 10 and stop maintaining it.

I will start that process so that QA can validate the tooling.

Thanks,
LuĂ­s Pinho

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.