Reputation: 3001
I am trying to write my own home automation system in javascript. The system should have a UI so that I can access some general controls for it.
Since it requires a UI, I thought "why not make it a fat electron app". So I am now trying out electron and svelte. But the issue I am running into is that it doesn't look like I am able to import my normal packages for controlling philips hue.
For example if I import philips-hue
with
import Hue from "philips-hue";
it immediately throws a ReferenceError: events is not defined
and if I try using the package node-hue-api
it throws the same error but references url
instead of events
This is quite confusing for me since I have used these packages many times before without issues when I am writing a normal node express server.
So I am wondering why it won't work on electron and svelte, and if there is any "quick fix" solutions that solves this issue?
Upvotes: 0
Views: 972
Reputation: 2454
You will need to polyfill the nodejs built-ins, as these do not exist in other environments such as electron.
If you are using webpack for example, you can follow the directions here: https://webpack.js.org/configuration/node
Upvotes: 1