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

170
Views
Using ‘require’ for browser-side js on module installed with npm

I’m building a Figma plugin and need to make a POST request to another API, so I installed the node package ‘node-fetch’ with npm i node-fetch, and am trying to bring it into my project with: const fetch = require(‘node-fetch’);

However, I’m getting “ReferenceError: ‘require’ is not defined”. Figma plugins, by my understanding, run in a browser-like environment. How do I use require in this context? Thanks!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can't use require() or node-fetch in a browser.

fetch() is built-into a browser already. Just use that.

node-fetch does not run in a browser. It's built on nodejs-specific code (the nodejs http module) and its job is to emulate the implementation of fetch() in a browser.

So, just use the browser's own fetch() implementation. Here's the doc.

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!