I was trying to make an OBS extension when I ran into a problem with importing the module in the first place. I’m working in ES6, and using the Kruiz Control approach of making OBS load a webpage that connects to a local Websocket, and currently all I’m asking it to do is display the scene it switched to.
I verified that I had obs-websocket-js installed and then searched online about the nuances of import, however the suggested changes- switching out the * for OBSWebSocket, trying to use import ‘obs-websocket-js’, adding/removing type="module" from the script tag, and using require instead of import- yielded similar results.
import * as OBSWebSocket from 'obs-websocket-js' // The problem line
const obs = new OBSWebSocket();
await obs.connect(IP_REMOVED, PASSWORD_REMOVED)
obs.on('CurrentProgramSceneChanged', scene => {
console.log(scene)
})
If there’s any alternative, or a fix to this, that would be greatly appreciated.
Edited to include the way the script is loaded.
2
Answers
I resorted to just using Node. This is the finalized code snippet.
Try put semicolon after the package name, like this:
import * as OBSWebSocket from 'obs-websocket-js';