Iām also trying to use Nakama with PlayCanvas, if anyone has any suggestions that would be welcome.
Iāve just put nakama-js.umd.js in the scripts folder, and then in my other .js script in the initialize() function, I use OPās code to import Nakama (just the 3 lines of code in his post), but the Chrome debug log shows: Failed to load resource: the server responded with a status of 404 (Not Found)
EDIT: Nakamaās documentaion (https://heroiclabs.com/docs/javascript-client-guide/) explains that the only requirement is to include nakama-js.umd.js in the script html tag. So Iām about to search the forums for how to do that.
If you have nakama-js.umd.js in the project, then itās automatically added to the header. Just make sure that it is first in the script loading order in the project settings.
We were experiencing the same issue as the code does indeed 404. It looks like the following line is the culprit:
nakamajs.src = ā/nakama-js.umd.jsā;
I think this defaults to the root and looking at where other scripts are located this seems to be wrong. My guess is it should be something like the following but we actually fixed it an alternative way so canāt confirm this:
What we actually did to remedy this was to remove the three lines where it creates the script tag for Nakama-js.umd.js and adds it to the head. Now obviously the script is no longer in the header so to get it into the header we went to the Nakama-js.umd.js file in the editor and in the inspector the is a drop down under āLoading Typeā. By changing this to āBefore Engineā actually adds this necessary file to the header for you thus no longer requiring the code to add it manually. This resolved the 404 error for us.
You donāt need to import nakama client as a src. when you put the script as #1 in the āscript load orderā section nakamajs.client is available by default from any script. so you only need to create a object reference for it.
client = new nakamajs.Client("defaultkey", "134.209.219.5", "7350");
The script asset works for me when is configured as āassetā āpreloadā and is in the first items in the load order array.