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

351
Visualizações
"Uncaught SyntaxError: Cannot use import statement outside a module" error while using parcel v2 to bundle JavaScript

I get this error regarding two scripts that I'm trying to load from my index.html file:

<script type="module"
src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>

<script type="module"
src="https://widgets.api-sports.io/football/1.1.8/widget.js"></script>

For some reason the problem only occures when I'm using Parcel to bundle my code. If I use live-server to preview the page, the scripts load with no problems.

package.json file:

 {
  "name": "footballstatsil",
  "version": "1.0.0",
  "description": "A website for football statistics",
  "default": "controller.js",
  "scripts": {
    "dev": "parcel index.html",
    "build": "parcel build index.html"
  },
  "author": "Dror Salomon",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.24.0",
    "parcel": "^2.0.0"
  }
}

So when I hit "npm run dev", I get the "Uncaught SyntaxError: Cannot use import statement outside a module" error and the scripts do not load.

Would really appriciate any help with this issue, thanks!

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

0

Ok so I executed the "npm run build" script and then executed the "npm run dev" script and everything seems to work...

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