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

286
Views
Browser-based JS module import failing

Am trying to implement reusable code blocks in JS. According to the documentation at ExploringJS, the following approach should work:

<script language="javascript" type="module">
   import declarePasswordEventHandlers from '/pathTo/password_event_handlers.js';
</script>
<script language="javascript">
   $( 'document' ).ready( function() { 
      declarePasswordEventHandlers(); 
   });
</script>

The imported module looks like this:

export default function declarePasswordEventHandlers() { 
   // event handlers being declared
}

When I load the page, I get the following error: screenshot of error messages

I've also tried:

<script language="javascript" type="module">
   import { declarePasswordEventHandlers } from '/pathTo/password_event_handlers.js';
</script>
<script language="javascript">
   $( 'document' ).ready( function() { 
       declarePasswordEventHandlers(); 
   });
</script>

and:

<script language="javascript" type="module">
   import * as passHandlerLib from '/pathTo/password_event_handlers.js';
</script>
<script language="javascript">
   $( 'document' ).ready( function() { 
      passHandlerLib.declarePasswordEventHandlers(); 
   });
</script>

Both used the selfsame export file as above, but with the default keyword removed from the export statement:

export function declarePasswordEventHandlers() { 
   // event handlers being declared
}

None of these approaches work; I get the same exact error shown in the attached screenshot.

What am I missing here?

about 4 years ago · Juan Pablo Isaza
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!