-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Once I set nodeIntegration: false in webPreferences I get this error:
"Uncaught ReferenceError: require is not defined at Object.url (external "url":1)
Clicking on "external 'url': 1" I get this line of code: module.exports = require("url")
Once I set nodeIntegration:false I get this error: "Uncaught ReferenceError: require is not defined at Object.url (external "url":1) "
enter image description here
Clicking on "external 'url': 1" I get this line of code: module.exports = require("url")
And once I set back to nodeIntegration: true, the error disappears.
I tried also to modify tsconfig.json as follows:
{
"compilerOptions": {
"target": "es6",
"module": "ES2020",
"lib": [
"dom",
"es2015",
"es2016",
"es2017"
],
"allowJs": true,
"jsx": "react",
"sourceMap": true,
"outDir": "./dist",
"strict": true ,
"esModuleInterop": true,
}
}
and add a /electron/types/node.d.ts file :
// https://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules
declare module "url" {
export interface Url {
protocol?: string;
hostname?: string;
pathname?: string;
}
export function parse(
urlStr: string,
parseQueryString?,
slashesDenoteHost?
): Url;
}
declare module "path" {
export function normalize(p: string): string;
export function join(...paths: any[]): string;
export var sep: string;
}
declare module "require"
But the problem persists.
node version: v.14.5.0
electron version: 10.1.3
webpack version: 4.44.2
webpack-cli version: 3.3.12
webpack-dev-server version: 3.11.0
react version: 16.13.1
typescript version: 4.0.3
OS: Ubuntu 18.04.4 Desktop
How to solve the problem, while keeping nodeIntegration:false + contextIsolation:true for strict security reasons?

