I want to use an external package called livekit-client, but I cannot call it properly.
It looks like the package import is not working.
The version of cocos creator I am using is 3.1.1.
The error does not occur in the 2.n series.
If you know anything about this, please give me some advice.
1, Install the npm package
→npm install livekit-client
2, I’ll call it up.
import pkg from "livekit-client";
const { connect } = pkg;
const url = "ws://localhost:7880";
const token = "my_token";
async start() {
...
let con = await connect(url, token);
...
}
■error
Error: Unable to resolve bare specifier ‘events’ from http://localhost:7456/scripting/x/mods/file/C:/Users/owner/Desktop/Projects/TestGame/node_modules/livekit-client/dist/room/participant/Participant.js (SystemJS Error#8 https://git.io/JvFET#8)
at throwUnresolved (resolve.js:12)
at SystemJS.systemJSPrototype.resolve (resolve.js:8)
at SystemJS.systemJSPrototype.resolve (named-register.js:45)
at system-core.js:145
at Array.map ()
at system-core.js:143
Both “events” and “livekit-client” are included in node_modules.