Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron - ReferenceError: Worker is not defined #27

Closed
ahrimov opened this issue Mar 20, 2024 · 1 comment
Closed

Electron - ReferenceError: Worker is not defined #27

ahrimov opened this issue Mar 20, 2024 · 1 comment

Comments

@ahrimov
Copy link

ahrimov commented Mar 20, 2024

Have testing spl.js with electron and got this error "ReferenceError: Worker is not defined".
Here is my code (main.js - Node.js environment):

import { app, BrowserWindow } from 'electron';
import SPL from 'spl.js';

const createWindow = async () => {
    const spl =  await SPL(); // getting errorMessage on this line
    const db = await spl.db();
}

app.whenReady().then(() => {
    createWindow();
});

package.json:

{
  "name": "y",
  "version": "1.0.0",
  "description": "\"Desktop electron app\"",
  "main": "main.js",
  "type": "module",
  "scripts": {
    "start": "electron .",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron": "^29.1.4"
  },
  "dependencies": {
    "spl.js": "^0.1.1"
  }
}

What am I doing wrong? Please help me!

@jvail
Copy link
Owner

jvail commented Mar 21, 2024

If you run spl in node you need to import the mjs which has a fully synchronous api:

import SPL from '../dist/index.mjs';

I guess if you use the BrowserWindow then you need to load it there. For example inside the index.html: win.loadFile('index.html'). I seems in your example it still runs in node - with no worker api available.

@jvail jvail closed this as completed Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants