title: Using node-fetch in js file in browser and in node
body: <p>I have built a class to do some fetch from an API and construct a suited response for my app.</p>
  <p>I use this file both in an app that run on the browser, and on a CLI app to work on the terminal.</p>
  <p>As I built the browser app first, there was no import to node-fetch.
  Now when I try to use this .js file in my CLI app, it returns error saying <code>fetch is not defined</code>.</p>
  <p>If I add to my api client .js file: <code>import fetch from &quot;node-fetch&quot;</code> then now my browser app is not working as well, print to the console:</p>
  <p><code>Uncaught TypeError: Failed to resolve module specifier &quot;node-fetch&quot;. Relative references must start with either &quot;/&quot;, &quot;./&quot;, or &quot;../&quot;.</code></p>
  <p>Is there anyway to apply fetch and use the same file for both?</p>
  <p>Thanks</p>