Before I move on to the next part of this tutorial, I want to acknowledge and resolve some of the mistakes that I did in the previous part, which only came to my attention after reading the comments. As you might know, when I initially developed this tutorial, I was using node version 21.7.3, and I told you that you can upgrade to the latest long-term support version. In my case, that would be 22.14.0, So some of you might have been using this version. Let's double check 22.14.0. But what happens if you try running generate types, for example, one of the scripts we have added.
As you can see, we get the error module not found issue. But not only for this script. You are most likely getting the same error if you try cleaning your database. So it is definitely a hiccup in this tutorial, which I think it's important to resolve. That being said, if you're already watching part two, you have most likely figured this out yourselves, but still I want to show you how you can fix it.
One quick and easy fix is to simply use the latest version. I mean an older version that I'm using 21.7.3. Once you switch to that version, so the exact one that I'm using, you can feel free to try bun run generate types, for example, and you will see no more errors. But that isn't exactly the best fix. What if you really, really want to use the latest long term support version like 22.14.0?
One thing that you can do is you can add type module to your package.json file and once you do that go ahead and try it again. So 22.14.0, bun, run, generate types and there we go no more errors here either. And one more thing that I have noticed is that when I developed the plugins, user has access to all tenants function. I told you that the roles is not typed, even though in our users collection here we have clearly defined the roles. You can fix this quite easily by simply adding a config which you can import from .slash payload types.
You can see it right here, .slash payload types. And now once you have config and save the file, you can see that user.roles is correctly typed. So just those two things I wanted to show you how to resolve but as I've said if you have come this far in the tutorial You have probably found your way around these issues, so you can just continue doing whatever you're doing. And let's go ahead and start chapter 17.