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

654
Visualizações
D3 7.0.0 SyntaxError: Unexpected token 'export'

I'm trying to import d3 into my node application but I'm getting the following error:

$ node src/main.js
this is logged from main.js 2021-07-20 2:33 PM
/Users/michaelosofsky/Developer/shh/node_modules/d3/src/index.js:1
export * from "d3-array";
^^^^^^

SyntaxError: Unexpected token 'export'
    at Module._compile (internal/modules/cjs/loader.js:892:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/michaelosofsky/Developer/shh/src/main.js:3:10)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I tried following the method of importing d3 described in How to use D3 in Node.js properly?:

  1. yarn add d3 (added 7.0.0 to my package.json)
  2. Put var d3 = require("d3"); in my main.js
  3. Run node src/main.js

This seems to be exactly what's specified in answers such as https://stackoverflow.com/a/9949301/2848676.

How to I work around this error?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I found I could work around this issue by downgrading the version of d3 I was using:

  1. yarn remove d3
  2. yarn add d3@4.12.2
  3. node src/main.js

Now it does not give me that error anymore.

I don't know the nuances of node module conventions well enough to explain it but I do see a change in d3 7.0.0 that pertains to modules, so maybe that had something to do with the root cause: https://github.com/d3/d3/issues/3501.

over 4 years ago · Santiago Trujillo 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