From 5d5cd456f0af67c2b0209935f8ca09e18bc4fb4a Mon Sep 17 00:00:00 2001
From: Andrey Goncharov <andrey@goncharov.page>
Date: Mon, 30 May 2022 10:43:11 +0100
Subject: [PATCH] Fix missing `fetch` function for webpack bundles

In electron setup, bundlers usually bundle for browser environments. In browser envs, bundles seem to pick up .mjs files first. .mjs fro node-fetch exports fetch as a default export. This fix allows bundling of npm-api for electron.
---
 lib/registry.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/registry.js b/lib/registry.js
index 227f787..391390e 100644
--- a/lib/registry.js
+++ b/lib/registry.js
@@ -1,6 +1,9 @@
 'use strict';
 
-const fetch = require('node-fetch');
+let fetch = require('node-fetch');
+if (fetch.default) {
+  fetch = fetch.default; 
+}
 const utils = require('./utils.js');
 const config = require('./config.js');