Uncaught ReferenceError: JsMediaSDK_Instance is not defined

Description
I have successfully integrated Video SDK in our react js application. I am be join multiple participant with their roles. but sometimes it keep getting error when joining/creating the session. There are two errors below. Do I miss anything ?

Error
Uncaught ReferenceError: JsMediaSDK_Instance is not defined
Uncaught TypeError: Cannot read properties of undefined (reading ‘userRole’)

Which Web Video SDK version?
1.4.0

To Reproduce(If applicable)
Steps used to join a Session

Screenshots

I found similar issue over here https://devforum.zoom.us/t/uncaught-syntaxerror-unexpected-token-in-video-sdk/47751
but the solutions didn’t work for me

Thank You
Gourish Mesta

Hey @gourishmesta1993

Thanks for your feedback.

When you call the init method, did you set the second parameter(‘dependentAssets’)? Could you open the devtools and in the ‘network’ tab, then locate the ‘js_media.min.js’ request? Is the HTTP response of this request correct?

Thanks
Vic

@vic.yang

Yes when i call the init method i set the second parameter (‘dependenetAssets’) as CDN

When the user is successfully able to join the session then below is the network tab screenshot

Unfortunately i am not able to replicate that issue so that i can share u the screenshot of network tab of ‘js_media.min.js’ request .

Once i get this same error ill post it here.

Thank You

hello gourish
it’ll help you after add init like this
all error will remove
zmClient.init(“en-US”, ${window.location.origin}/lib);

Hi @shivam.kumar

Thank You for the workaround

I’ll add this code and check

Hi @shivam.kumar

after using the code provided by you i am getting even more error

Uncaught SyntaxError: Unexpected token '<' (at js_media.min.js:1:1)
index.umd.js:1 Uncaught ReferenceError: JsMediaSDK_Instance is not defined
    at Fi.init (index.umd.js:1:1)
    at index.umd.js:1:1
    at t.project (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at e.observe (index.umd.js:1:1)
    at t.dispatch (index.umd.js:1:1)
    at t._execute (index.umd.js:1:1)
    at t.execute (index.umd.js:1:1)
    at t.flush (index.umd.js:1:1)
    at t.schedule (index.umd.js:1:1)
    at e.schedule (index.umd.js:1:1)
    at t.schedule (index.umd.js:1:1)
    at t.scheduleMessage (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at Object.next (index.umd.js:1:1)
    at t.__tryOrUnsub (index.umd.js:1:1)
init @ index.umd.js:1
(anonymous) @ index.umd.js:1
(anonymous) @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
e.observe @ index.umd.js:1
t.dispatch @ index.umd.js:1
t._execute @ index.umd.js:1
t.execute @ index.umd.js:1
t.flush @ index.umd.js:1
t.schedule @ index.umd.js:1
e.schedule @ index.umd.js:1
t.schedule @ index.umd.js:1
t.scheduleMessage @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
next @ index.umd.js:1
t.__tryOrUnsub @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
n @ index.umd.js:1
(anonymous) @ index.umd.js:1
emit @ index.umd.js:1
(anonymous) @ index.umd.js:1
setTimeout (async)
(anonymous) @ index.umd.js:1
t.error @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
e.observe @ index.umd.js:1
t.dispatch @ index.umd.js:1
t._execute @ index.umd.js:1
t.execute @ index.umd.js:1
t.flush @ index.umd.js:1
t.schedule @ index.umd.js:1
e.schedule @ index.umd.js:1
t.schedule @ index.umd.js:1
t.scheduleMessage @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
next @ index.umd.js:1
t.__tryOrUnsub @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
n @ index.umd.js:1
(anonymous) @ index.umd.js:1
emit @ index.umd.js:1
(anonymous) @ index.umd.js:1
Show 101 more frames
index.umd.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'userRole')
    at t.project (index.umd.js:1:1)
    at t._tryNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at e.observe (index.umd.js:1:1)
    at t.dispatch (index.umd.js:1:1)
    at t._execute (index.umd.js:1:1)
    at t.execute (index.umd.js:1:1)
    at t.flush (index.umd.js:1:1)
    at t.schedule (index.umd.js:1:1)
    at e.schedule (index.umd.js:1:1)
    at t.schedule (index.umd.js:1:1)
    at t.scheduleMessage (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t.notifyNext (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at t._next (index.umd.js:1:1)
    at t.next (index.umd.js:1:1)
    at index.umd.js:1:1
(anonymous) @ index.umd.js:1
t._tryNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
e.observe @ index.umd.js:1
t.dispatch @ index.umd.js:1
t._execute @ index.umd.js:1
t.execute @ index.umd.js:1
t.flush @ index.umd.js:1
t.schedule @ index.umd.js:1
e.schedule @ index.umd.js:1
t.schedule @ index.umd.js:1
t.scheduleMessage @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
(anonymous) @ index.umd.js:1
(anonymous) @ index.umd.js:1
setTimeout (async)
(anonymous) @ index.umd.js:1
t.error @ index.umd.js:1
t._tryNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
e.observe @ index.umd.js:1
t.dispatch @ index.umd.js:1
t._execute @ index.umd.js:1
t.execute @ index.umd.js:1
t.flush @ index.umd.js:1
t.schedule @ index.umd.js:1
e.schedule @ index.umd.js:1
t.schedule @ index.umd.js:1
t.scheduleMessage @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.notifyNext @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
(anonymous) @ index.umd.js:1
(anonymous) @ index.umd.js:1
setTimeout (async)
next @ index.umd.js:1
t.__tryOrUnsub @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
t._next @ index.umd.js:1
t.next @ index.umd.js:1
n @ index.umd.js:1
(anonymous) @ index.umd.js:1
emit @ index.umd.js:1
(anonymous) @ index.umd.js:1
Show 73 more frames

Changing the code back to client.init("en-US", CDN); works fine

Thank You

If you are using any script file and getting "Uncaught ReferenceError: x is not defined " which means ‘x’ is either a variable or a method which you are trying to use before declaring it using var keyword. This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this ‘x’ is not defined error . This usually indicates that your library is not loaded and JavaScript does not recognize the ‘x’.

To solve this error: Load your library at the beginning of all your scripts.

There can be multiple other reasons for this issue:

  • Conflict with Other Libraries
  • Path to your library included is not correct
  • Llibrary file is corrupted
  • Working offline (when you use CDN)
1 Like