Skip to content

Commit e89abed

Browse files
authored
fix: disable use of the vm module in the renderer (electron#26087)
1 parent c89ce5e commit e89abed

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/common/reset-search-paths.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ const Module = require('module');
55
// Clear Node's global search paths.
66
Module.globalPaths.length = 0;
77

8+
// We do not want to allow use of the VM module in the renderer process as
9+
// it conflicts with Blink's V8::Context internal logic.
10+
if (process.type === 'renderer') {
11+
const _load = Module._load;
12+
Module._load = function (request: string) {
13+
if (request === 'vm') {
14+
console.warn('The vm module of Node.js is deprecated in the renderer process and will be removed.');
15+
}
16+
return _load.apply(this, arguments);
17+
};
18+
}
19+
820
// Prevent Node from adding paths outside this app to search paths.
921
const resourcesPathWithTrailingSlash = process.resourcesPath + path.sep;
1022
const originalNodeModulePaths = Module._nodeModulePaths;

0 commit comments

Comments
 (0)