Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use a proxy with Node and ESM?

Tags:

node.js

In the olden days I had something like this...

const HttpsProxyAgent = require("https-proxy-agent");
new HttpsProxyAgent(URL)

However when I convert to ESM...

import HttpsProxyAgent from "https-proxy-agent";
// Also tried
// import * as HttpsProxyAgent from "https-proxy-agent";
new HttpsProxyAgent(URL)

I get...

(node:7856) UnhandledPromiseRejectionWarning: TypeError: HttpsProxyAgent is not a constructor

So how do I accomplish this now? Is there a native ES6 proxy that node supports?

like image 299
JGleason Avatar asked Dec 21 '25 21:12

JGleason


1 Answers

you can also do:

new HttpsProxyAgent.HttpsProxyAgent(URL);
like image 194
Mistriel Avatar answered Dec 24 '25 10:12

Mistriel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!