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 @@ -629,6 +629,14 @@ added: v9.0.0
629629Disables runtime checks for ` async_hooks ` . These will still be enabled
630630dynamically when ` async_hooks ` is enabled.
631631
632+ ### ` --no-global-search-paths `
633+ <!-- YAML
634+ added: REPLACEME
635+ -->
636+
637+ Do not search modules from global paths like ` $HOME/.node_modules ` and
638+ ` $NODE_PATH ` .
639+
632640### ` --no-warnings `
633641<!-- YAML
634642added: v6.0.0
@@ -1442,6 +1450,7 @@ Node.js options that are allowed are:
14421450* ` --no-experimental-repl-await `
14431451* ` --no-extra-info-on-fatal-exception `
14441452* ` --no-force-async-hooks-checks `
1453+ * ` --no-global-search-paths `
14451454* ` --no-warnings `
14461455* ` --node-memory-debug `
14471456* ` --openssl-config `
Original file line number Diff line number Diff line change @@ -285,6 +285,9 @@ Disable the `node-addons` exports condition as well as disable loading native
285285addons. When `--no-addons` is specified, calling `process.dlopen` or requiring
286286a native C++ addon will fail and throw an exception.
287287.
288+ .It Fl -no-global-search-paths
289+ Do not search modules from global paths.
290+ .
288291.It Fl -no-warnings
289292Silence all process warnings (including deprecations).
290293.
Original file line number Diff line number Diff line change @@ -887,7 +887,8 @@ inline bool Environment::hide_console_windows() const {
887887}
888888
889889inline bool Environment::no_global_search_paths () const {
890- return flags_ & EnvironmentFlags::kNoGlobalSearchPaths ;
890+ return (flags_ & EnvironmentFlags::kNoGlobalSearchPaths ) ||
891+ !options_->global_search_paths ;
891892}
892893
893894bool Environment::filehandle_close_warning () const {
Original file line number Diff line number Diff line change @@ -407,6 +407,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
407407 &EnvironmentOptions::allow_native_addons,
408408 kAllowedInEnvironment ,
409409 true );
410+ AddOption (" --global-search-paths" ,
411+ " disable global module search paths" ,
412+ &EnvironmentOptions::global_search_paths,
413+ kAllowedInEnvironment ,
414+ true );
410415 AddOption (" --warnings" ,
411416 " silence all process warnings" ,
412417 &EnvironmentOptions::warnings,
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ class EnvironmentOptions : public Options {
122122 bool deprecation = true ;
123123 bool force_async_hooks_checks = true ;
124124 bool allow_native_addons = true ;
125+ bool global_search_paths = true ;
125126 bool warnings = true ;
126127 bool force_context_aware = false ;
127128 bool pending_deprecation = false ;
You can’t perform that action at this time.
0 commit comments