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

102
Visualizações
How to use module type in ejs?

I want to import react in ejs it shows cannot use import statement outside module.

import React from react

When I execute this ^^^ I get error cannot use import statement outside module.

const {React} = require("react")

When I run this ^^^ it gives me error require is not defined...

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

0

You need to set your script type as module to be able to use import statement / ES Module :

If you are using node.js, you have to edit your package.json and set :

{
    "type": "module",
}

Else, if you import your js script from an html balise you have to set (almost the same thing) :

<script src="app.js" type="module" ></script>

This will enable the use of import inside app.js

about 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