To fix this error you need to be using a version of node12+ however this may not solve the error on some browsers.
I recommend adding a polyfill for globalThis to ensure that the error is fixed over every environment.
npm i globalthis
inside polyfill.js add the following line
or import it into your file using
var globalThis = require('globalthis/polyfill')();