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

186
Visualizações
d3 in node and in browser - How to import?

I simply can't understand what the best way is to import and use all the functionality of d3 in node and in the browser. This certainly has to do with my limited understanding of the differences of require. import and importing d3 in a script-tag.

When should I use what? Should I, for example when I want to read a file in node, just install npm install d3 and then I have access to e.g. the d3's csvfunction via

import {csv } from "d3-fetch ?

For example I have this little script:

import { csv } from 'd3-fetch'
let path = './data.csv'
let data = await csv(path)
console.log(data)

In my package.json I have:

"dependencies": {
    "d3-fetch": "^3.0.1"
}

But still I get the error:

ReferenceError: fetch is not defined

I'd be super happy to receive any pointer to good ressources to learn about how imports should work. For me this simply isn't trivial. I know there are some ressources on SO, but none really helped me so far. I'm sorry for this very simple, yet confusing question...

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Nothing looks wrong with your import statements. Node does not natively support the fetch API which is why you get a reference error. The creator of D3 actually answered this question here.

about 4 years ago · Juan Pablo Isaza Relatório
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