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

207
Visualizações
Using require in TypeScript in order to load modules in the browser

I have a web page on which I would like to use a TypeScript file I created. That web page uses a few modules, most importantly vega-lite, papaparse, and tabulator-tables. I would like to load them into the code via TypeScript, and when I attempt to write into the TS file a line such as the following:

const Papa = require("papaparse");

I don't get any errors on compiling, but when I load the HTML page I get a require is not defined error. I suspect it has something to do with my tsconfig.json, so I'm attaching it. Does anyone know how to solve this? The structure of my project is:

node_modules
public
    index.html
    styles.css
    index.js
src
    index.ts

And this is my tsconfig.json file:

{   
  "compilerOptions":
  {
    "target": "es2021",
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "./public",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitAny": false,
    "strictNullChecks": false,
    "skipLibCheck": true
  }
}
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