Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda