Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
Can I customize imports for binary files in javascript? Module not found error

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 ๐Ÿ‘‡

enter image description here

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

about 4 years ago ยท Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!