Function Fetch (cross-fetch/polyfill)

I found some javascript that uses the function called fetch.
When I try to use in a node it gives me an error.

I tried adding this to my settings.js

functionGlobalContext: {
fetch:require(“cross-fetch/polyfill”),
// os:require(‘os’),
// jfive:require(“johnny-five”),
// j5board:require(“johnny-five”).Board({repl:false})
},

But that just gave a config error

Then I thought I need to install it.
“npm install fetch-polyfill --save”
That works fine - but the issue is that when the container is restarted in HA, the container is reset. So an “in-container” install won’t work.

What can I do ?

Add fetch-polyfill to the npm section on the nodered configuration page inside the addon.

Okay - I did that

npm_packages:
  - fetch-polyfill

Still I am getting the error

TypeError: fetch is not a function

If I change the settings.js Node Red still won’t start.

You can try the full command npm install fetch-polyfill under the init section but leave off --save

Same error. Maybe I am doing my JS wrong.

fetch = global.get("fetch")
fetch('https.........