fireship-io / 223-electron-screen-recorder

Episode 223 - Build a Screen Recorder with Electron
273 stars 146 forks source link

Require is not defined !! #49

Open berk-efe opened 1 year ago

berk-efe commented 1 year ago

Hello I am trying to learn electron and javascript but i encounter this error like a lot... and i realy dont get why i got this error.

There is literally no difference on my render.js script:

// Buttons
const videoElement = document.querySelector('video');
const startBtn = document.getElementById('startBtn');
const stopBtn = document.getElementById('stopBtn');
const videoSelectBtn = document.getElementById('videoSelectBtn');
videoSelectBtn.onclick = getVideoSources;

const { desktopCapturer, remote } = require('electron');
const { Menu } = remote;

async function getVideoSources() {
    const inputSources = await desktopCapturer.getSources({
        types: ['window', "screen"]
    });

    const videoOptionsMenu = Menu.buildFromTemplate(
        inputSources.map(source => {
            inputSources.map(source => {
                return {
                    label: source.name,
                    click: ( ) => selectSource(source)
                }
            })
        })
    );
};

Here is the error i get:

Uncaught ReferenceError: require is not defined
    at render.js:8:37

Can someone pls help me about this...?