javascriptvue.jsnuxt.jsvideo-playershaka

Shaka player - HTMLMediaElement is not defined


When I installed shaka player in Nuxt and mode: universal, I received this error:

enter image description here

In spa mode shaka is working but in universal it doesn't work.


Thanks to the answer, the issue was solved with the following:

if (process.client) {
  window.shaka = require('shaka-player/dist/shaka-player.compiled.js')
  require('shaka-player/dist/shaka-player.ui')
}

Solution

  • You did not provided any code, but I'm 90% sure that this is coming from the fact that window is not present when run on the server.

    My answer can be found here: How to fix navigator / window / document is undefined in Nuxt