diff --git a/lib/common/reset-search-paths.ts b/lib/common/reset-search-paths.ts index de2cac114b3b..d3294735bc06 100644 --- a/lib/common/reset-search-paths.ts +++ b/lib/common/reset-search-paths.ts @@ -5,6 +5,18 @@ const Module = require('module'); // Clear Node's global search paths. Module.globalPaths.length = 0; +// We do not want to allow use of the VM module in the renderer process as +// it conflicts with Blink's V8::Context internal logic. +if (process.type === 'renderer') { + const _load = Module._load; + Module._load = function (request: string) { + if (request === 'vm') { + console.warn('The vm module of Node.js is deprecated in the renderer process and will be removed.'); + } + return _load.apply(this, arguments); + }; +} + // Prevent Node from adding paths outside this app to search paths. const resourcesPathWithTrailingSlash = process.resourcesPath + path.sep; const originalNodeModulePaths = Module._nodeModulePaths;