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

182
Views
Node.js. How to get a path to imported file

I'm writing a parser and i'm getting imports like ../modules/greeting.js, also i have an absolute path to file (from where i have done an import) - for instance C:\Desktop\Folder\src\scripts\main.js.

How to get path to file which i have imported? (in this case it should be src/modules/greeting.js). Thanks!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use this for the absolute path to the imported file:

path.resolve(path.dirname('C:\\Desktop\\Folder\\src\\scripts\\main.js'), '../modules/greeting.js')

Returns: "C:\Desktop\Folder\src\modules\greeting.js"
Check the API docs for more path utils: https://nodejs.org/api/path.html

about 4 years ago · Juan Pablo Isaza Report
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!