Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
typescript "Uncaught ReferenceError: require is not defined"

guys, i have questions. How do i get filenames from a folder using typescript? I trying next way:

  1. I create folder and write command line "tsc --init" and create "tsconfig.json" where change options: "module": "es2015" and "target": "es6".
  2. I create "" in html code.
  3. I create file app.ts and write code:
import * as fs from 'fs';

class HTML_Element {
public html_element: HTMLElement;

constructor(html_string: string) {
    this.html_element = new HTMLElement();
    this.html_element.className = "gallery_item";
    this.html_element.innerHTML = html_string;
    }
}

const html_div: HTML_Element = new HTML_Element("FSDfdsfsd");

const list_image: any = fs.readdirSync('../image/')

console.log(list_image)

4.I write command in terminal "tsc app.ts" and get "app.js"

"use strict";
exports.__esModule = true;
var fs = require("fs");
var HTML_Element = /** @class */ (function () {
    function HTML_Element(html_string) {
        this.html_element = new HTMLElement();
        this.html_element.className = "gallery_item";
        this.html_element.innerHTML = html_string;
    }
    return HTML_Element;
}());
var html_div = new HTML_Element("<div>FSDfdsfsd</div>");
var list_image = fs.readdirSync('../image/');
console.log(list_image);

5.I get error in the browser: Uncaught ReferenceError: require is not defined

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda