File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99const bootstrap = require ( './bootstrap' ) ;
1010
11+ // Remove global paths from the node module lookup
12+ bootstrap . removeGlobalNodeModuleLookupPaths ( ) ;
13+
1114// Enable ASAR in our forked processes
1215bootstrap . enableASARSupport ( ) ;
1316
Original file line number Diff line number Diff line change @@ -53,6 +53,29 @@ exports.injectNodeModuleLookupPath = function (injectPath) {
5353} ;
5454//#endregion
5555
56+ //#region Remove global paths from the node lookup paths
57+
58+ exports . removeGlobalNodeModuleLookupPaths = function ( ) {
59+ // @ts -ignore
60+ const Module = require ( 'module' ) ;
61+ // @ts -ignore
62+ const globalPaths = Module . globalPaths ;
63+
64+ // @ts -ignore
65+ const originalResolveLookupPaths = Module . _resolveLookupPaths ;
66+
67+ // @ts -ignore
68+ Module . _resolveLookupPaths = function ( moduleName , parent ) {
69+ const paths = originalResolveLookupPaths ( moduleName , parent ) ;
70+ let commonSuffixLength = 0 ;
71+ while ( commonSuffixLength < paths . length && paths [ paths . length - 1 - commonSuffixLength ] === globalPaths [ globalPaths . length - 1 - commonSuffixLength ] ) {
72+ commonSuffixLength ++ ;
73+ }
74+ return paths . slice ( 0 , paths . length - commonSuffixLength ) ;
75+ } ;
76+ } ;
77+ //#endregion
78+
5679//#region Add support for using node_modules.asar
5780/**
5881 * @param {string= } nodeModulesPath
You can’t perform that action at this time.
0 commit comments