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

169
Visualizações
ES6 import statements not working on web server

My imports work fine within my javascript file, but they do not work when I start the webserver. I can access the functions of the imported module as expected, but the import statement itself fails when I boot up the nodejs server.

I added the following import statement without error to the top of a javascript class

import * as Ably from 'ably';

My HTML file has this at the end of the body tag

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

I get the following error from inspect element (no errors in vscode)

Uncaught TypeError: Failed to resolve module specifier "ably". Relative references must start with either "/", "./", or "../".

I tried changing the file path

import * as Ably from './node_modules/ably/ably.js';

but this gave me 404 errors

GET http://localhost:3000/node_modules/ably/ably.js net::ERR_ABORTED 404 (Not Found)
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try using <script src="https://cdn.ably.com/lib/ably.min-1.js"></script> in HTML file instead of import. Also, check this thread, looks similar to your problem Failed to resolve module

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