File tree Expand file tree Collapse file tree 5 files changed +20
-1
lines changed Expand file tree Collapse file tree 5 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -619,6 +619,14 @@ added: v9.0.0
619
619
Disables runtime checks for ` async_hooks ` . These will still be enabled
620
620
dynamically when ` async_hooks ` is enabled.
621
621
622
+ ### ` --no-global-search-paths `
623
+ <!-- YAML
624
+ added: REPLACEME
625
+ -->
626
+
627
+ Do not search modules from global paths like ` $HOME/.node_modules ` and
628
+ ` $NODE_PATH ` .
629
+
622
630
### ` --no-warnings `
623
631
<!-- YAML
624
632
added: v6.0.0
@@ -1431,6 +1439,7 @@ Node.js options that are allowed are:
1431
1439
* ` --no-deprecation `
1432
1440
* ` --no-experimental-repl-await `
1433
1441
* ` --no-force-async-hooks-checks `
1442
+ * ` --no-global-search-paths `
1434
1443
* ` --no-warnings `
1435
1444
* ` --node-memory-debug `
1436
1445
* ` --openssl-config `
Original file line number Diff line number Diff line change @@ -282,6 +282,9 @@ Disable the `node-addons` exports condition as well as disable loading native
282
282
addons. When `--no-addons` is specified, calling `process.dlopen` or requiring
283
283
a native C++ addon will fail and throw an exception.
284
284
.
285
+ .It Fl -no-global-search-paths
286
+ Do not search modules from global paths.
287
+ .
285
288
.It Fl -no-warnings
286
289
Silence all process warnings (including deprecations).
287
290
.
Original file line number Diff line number Diff line change @@ -887,7 +887,8 @@ inline bool Environment::hide_console_windows() const {
887
887
}
888
888
889
889
inline bool Environment::no_global_search_paths () const {
890
- return flags_ & EnvironmentFlags::kNoGlobalSearchPaths ;
890
+ return (flags_ & EnvironmentFlags::kNoGlobalSearchPaths ) ||
891
+ !options_->global_search_paths ;
891
892
}
892
893
893
894
bool Environment::filehandle_close_warning () const {
Original file line number Diff line number Diff line change @@ -407,6 +407,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
407
407
&EnvironmentOptions::allow_native_addons,
408
408
kAllowedInEnvironment ,
409
409
true );
410
+ AddOption (" --global-search-paths" ,
411
+ " disable global module search paths" ,
412
+ &EnvironmentOptions::global_search_paths,
413
+ kAllowedInEnvironment ,
414
+ true );
410
415
AddOption (" --warnings" ,
411
416
" silence all process warnings" ,
412
417
&EnvironmentOptions::warnings,
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ class EnvironmentOptions : public Options {
122
122
bool deprecation = true ;
123
123
bool force_async_hooks_checks = true ;
124
124
bool allow_native_addons = true ;
125
+ bool global_search_paths = true ;
125
126
bool warnings = true ;
126
127
bool force_context_aware = false ;
127
128
bool pending_deprecation = false ;
You can’t perform that action at this time.
0 commit comments