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

135
Views
TypeScript: list files in web folder

I have a TypeScript web application with the following folder structure.

- assets
 |- a.png
 |- b.png
 |- c.png
 |- d.png
 |- ...
- app.ts

In app.ts, how do I programatically list all the files in assets folder?

I tried the below but it didn't work. And I also thought I may be going down the wrong path because fs is used to access the user's file system, which is not my intent.

const fs = require('fs');
const assets_folder = './assets/';
fs.readdirSync(assets_folder).forEach((file) => {
  console.log(file);
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The issue is related to file location because when you use the typescript after compiling., it'll move to dist/build and it'll look in that directory.

Solution: Copy files/directory from src to dist/build programatically, it'll solve your issue.

Project src

src
  assets
    images
  app.ts

After complie

dist
  //<Missing assets>
  app.js
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!