File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,9 @@ function addPath (path) {
82
82
if ( modulePaths . indexOf ( path ) === - 1 ) {
83
83
modulePaths . push ( path )
84
84
// Enable the search path for the current top-level module
85
- addPathHelper ( path , require . main . paths )
85
+ if ( require . main ) {
86
+ addPathHelper ( path , require . main . paths )
87
+ }
86
88
parent = module . parent
87
89
88
90
// Also modify the paths of the module that was used to load the
@@ -115,7 +117,9 @@ function addAlias (alias, target) {
115
117
function reset ( ) {
116
118
// Reset all changes in paths caused by addPath function
117
119
modulePaths . forEach ( function ( path ) {
118
- removePathHelper ( path , require . main . paths )
120
+ if ( require . main ) {
121
+ removePathHelper ( path , require . main . paths )
122
+ }
119
123
120
124
// Delete from require.cache if the module has been required before.
121
125
// This is required for node >= 11
You can’t perform that action at this time.
0 commit comments