Trying to use peaks.js in plugin, got: ReferenceError: navigator is not defined

System Information
  • Strapi Version: 3.6.8
  • Operating System: Windows 10
  • Database: sqlite3
  • Node Version: v14.17.5
  • NPM Version: 6.14.14
  • Yarn Version: 1.22.11

I am trying to use peaks.js in my plugin (respectively, plugin’s packages.json in the dependencies has: konva: “^ 8.1.3” and peaks.js: “^ 0.26.0”. With the build everything is ok, but when I run the strap develop, I get an error: ReferenceError: navigator is not defined

I understand that there is a code like this in peaks.js:
var isHeadless = /HeadlessChrome/.test(navigator.userAgent);
function windowIsVisible () {
if (isHeadless || navigator.webdriver) {
return false;
return typeof document === ‘object’ && ‘visibilityState’ in document && document.visibilityState === ‘visible’;

But I don’t understand how how to manage this)