wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
23.25k stars 1.1k forks source link

TypeError: undefined is not an object (evaluating 'window.wails._.Init') #3530

Closed maksemen2 closed 3 weeks ago

maksemen2 commented 3 weeks ago

Description

Getting this error when initializing wails in main.jsx file:

import React from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.jsx'
import './index.css'

import * as Wails from '@wailsapp/runtime';

const root = createRoot(
  document.getElementById('root')
);

Wails.Init(() => {
  root.render(
    <App />)
})

but it throws an error TypeError: undefined is not an object (evaluating 'window.wails._.Init')

Wanted to init wails to use this:
    useEffect(() => {
        Wails.Events.On("checker:checked", event => {
            console.log(event)
        });
    }, []);

where i also got an error TypeError: undefined is not an object (evaluating 'window.wails.Events.OnMultiple')

Also i noticed that i have libwebkit installed sudo apt install libwebkit2gtk-4.0-dev The newest version of libwebkit2gtk-4.0-dev (2.44.2-0ubuntu0.22.04.1) is already installed. 0 packages were updated, 0 new packages were installed, 0 packages were marked for removal, and 25 packages were not updated. But in wails doctor i get | libwebkit | libwebkit2gtk-4.0-dev | Available | 2.44.2-0ubuntu0.22.04.1 | Required package(s) installation details:

To Reproduce

  1. Try to load page
  2. See the error :)

Expected behaviour

Just a loaded page

Screenshots

No response

Attempted Fixes

No response

System Details

# Wails
Version         | v2.8.2
Package Manager | apt   

# System
┌───────────────────────────────────────────────────────────────────────────────┐
| OS           | Ubuntu                                                         |
| Version      | 24.04                                                          |
| ID           | ubuntu                                                         |
| Go Version   | go1.22.2                                                       |
| Platform     | linux                                                          |
| Architecture | amd64                                                          |
| CPU          | AMD Ryzen 5 3600 6-Core Processor                              |
| GPU 1        | Unknown                                                        |
| GPU 2        | GP104 [GeForce GTX 1080] (NVIDIA Corporation) - Driver: nvidia |
| Memory       | 32GB                                                           |
└───────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name          | Status    | Version                 |
| *docker    | docker.io             | Available | 24.0.7-0ubuntu4         |
| gcc        | build-essential       | Installed | 13.2.0                  |
| libgtk-3   | libgtk-3-dev          | Installed | 3.24.41-4ubuntu1        |
| libwebkit  | libwebkit2gtk-4.0-dev | Available | 2.44.2-0ubuntu0.22.04.1 |
| npm        | npm                   | Installed | 9.2.0~ds1-2             |
| *nsis      | nsis                  | Installed | v3.09-4                 |
| pkg-config | pkg-config            | Installed | 1.8.1                   |
└──────────────────────── * - Optional Dependency ─────────────────────────┘

# Diagnosis
Required package(s) installation details: 
  - libwebkit: sudo apt install libwebkit2gtk-4.0-dev

Optional package(s) installation details: 
  - docker: sudo apt install docker.io

Additional context

No response