Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!