First of all, thank you so much in advance if you are willing to help me out with this error! ๐
I have a Nextjs project and I have a jsconfig file with the following content in order to not use relative imports in the src code and it's working fine.
{
"compilerOptions": {
"baseUrl": "."
}
}
So thanks to this file, I can use imports like lib/file-name.js instead of ../../lib/file-name.js in all of the files that are underneath the /src directory, which is a game changer!
But the issue comes when I want to execute some binary files (scripts for generating SEO files, etc...) that use some files that are in the /src folder and are using these custom/absolute imports.
The reason why these binary files are using files from the /src directory is that I have a custom API fetcher for example, that I use in both places (binary files to get data when executing those files, and at build time)
I tried to update the import in that binary file for a relative one and it works fine as you can see in the image below ๐
And the error I get is the following ๐
Error: Cannot find module 'lib/fetch-from-api'
- Is there a way to add an extra configuration for such binary files?
- How is this usually handled? Because I would not like the idea of having all the imports in the applications using relative imports