Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

require or import statement don't work in "renderer.ts" #46

Closed
serge-hulne opened this issue Oct 30, 2020 · 2 comments
Closed

require or import statement don't work in "renderer.ts" #46

serge-hulne opened this issue Oct 30, 2020 · 2 comments

Comments

@serge-hulne
Copy link

require or import statement doesn't work in "renderer.ts"

Is this feature missing?

How do you divide the code into modules if the renderer needs to import stuff from a lib?

Thanks.

@erickzhao
Copy link
Member

Hey @serge-hulne, this quick-start has nodeIntegration disabled, so Node is not exposed to the renderer process. This is a default that's there for security purposes.

To enable Node integration, you can modify the mainWindow constructor in main.ts:

 // Create the browser window.
  const mainWindow = new BrowserWindow({
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, "preload.js"),
      nodeIntegration: true,
    },
    width: 800,
  });

@serge-hulne
Copy link
Author

Thanks,
But now I'm getting the error:

Uncaught ReferenceError: exports is not defined
    at renderer.js:2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants