# TypeError: window.require is not a function

window.require is not a function 이런 에러가 나올때 해결법입니다

electron의 main.js 파일에 contextIsolation: false를 추가합니다












 
 








const { app, BrowserWindow } = require("electron");

require("@electron/remote/main").initialize();

function createWindow() {
  const win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true,
      enableRemoteModule: true,
      // TypeError: window.require is not a function 일때 추가
      contextIsolation: false
    }
  });

  win.loadURL("http://localhost:3000");
}

app.on("ready", createWindow);
#etc #electron
노경환
이 글이 도움이 되셨다면! 깃헙 스타 부탁드립니다 😊😄
최근변경일: 3/25/2024, 12:16:11 PM