Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a67296

Browse filesBrowse files
zcbenzBethGriggs
authored andcommitted
src: add --no-global-search-paths cli option
PR-URL: #39754 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent 51f9ad4 commit 9a67296
Copy full SHA for 9a67296

File tree

Expand file treeCollapse file tree

5 files changed

+20
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+20
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/cli.md‎

Copy file name to clipboardExpand all lines: doc/api/cli.md
+9Lines changed: 9 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,14 @@ added: v9.0.0
619619
Disables runtime checks for `async_hooks`. These will still be enabled
620620
dynamically when `async_hooks` is enabled.
621621

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+
622630
### `--no-warnings`
623631
<!-- YAML
624632
added: v6.0.0
@@ -1431,6 +1439,7 @@ Node.js options that are allowed are:
14311439
* `--no-deprecation`
14321440
* `--no-experimental-repl-await`
14331441
* `--no-force-async-hooks-checks`
1442+
* `--no-global-search-paths`
14341443
* `--no-warnings`
14351444
* `--node-memory-debug`
14361445
* `--openssl-config`
Collapse file

‎doc/node.1‎

Copy file name to clipboardExpand all lines: doc/node.1
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ Disable the `node-addons` exports condition as well as disable loading native
282282
addons. When `--no-addons` is specified, calling `process.dlopen` or requiring
283283
a native C++ addon will fail and throw an exception.
284284
.
285+
.It Fl -no-global-search-paths
286+
Do not search modules from global paths.
287+
.
285288
.It Fl -no-warnings
286289
Silence all process warnings (including deprecations).
287290
.
Collapse file

‎src/env-inl.h‎

Copy file name to clipboardExpand all lines: src/env-inl.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,8 @@ inline bool Environment::hide_console_windows() const {
887887
}
888888

889889
inline bool Environment::no_global_search_paths() const {
890-
return flags_ & EnvironmentFlags::kNoGlobalSearchPaths;
890+
return (flags_ & EnvironmentFlags::kNoGlobalSearchPaths) ||
891+
!options_->global_search_paths;
891892
}
892893

893894
bool Environment::filehandle_close_warning() const {
Collapse file

‎src/node_options.cc‎

Copy file name to clipboardExpand all lines: src/node_options.cc
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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,
Collapse file

‎src/node_options.h‎

Copy file name to clipboardExpand all lines: src/node_options.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.