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

164
Views
How to import dynamically in Javascript with HTML

my problem is the following: I'm trying to run a JS function with a HTML button, but this error appears each time I click the button:

Uncaught (in promise) ReferenceError: require is not defined

Im pretty sure that it is because I'm using Puppeteer in my JS file, and the function which the button executes uses it.

const puppeteer = require('puppeteer');

I have the import on the top of the file, but I think HTML only executes the function and doesn't read the import.

So the thing here is, can I dynamically import the module inside my function?

Thanks in advance!

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!