PATH
An operating system environment variable used to locate executable files. It contains a list of directory paths, and the system searches these directories in order for the executable file corresponding to a command.
Core Facts
Checking "Add to PATH" during Node.js installation automatically adds the installation path to the system environment variable PATH, allowing the system to recognize the node and npm commands from any location.
A global npm install (`-g`) downloads the package to the global node_modules directory and creates an executable entry in Node's bin directory, which is in PATH by default; terminals that are already open will not pick up PATH changes, so the terminal needs to be reopened.
PATH is an environment variable in operating systems that tells the system which directories to search for executable programs.
Timeline (last 90 days)
On some systems automatically adding PATH may affect other Python environments, and if problems occur it can be configured manually.
If the bin directory of a globally installed npm package is not in the system PATH, a "command not found" message may still appear even after a successful installation.
If `node -v` shows "is not recognized as an internal or external command", it is usually because the installation path was not added to the system environment variables, and you need to reinstall or manually configure the PATH.
If the terminal reports 'command not found' after installing Gemini CLI, it usually means its installation directory is not in PATH, or the Node version does not meet the requirements.
After installation, you need to close the current terminal and reopen it, because globally installed executables require the PATH environment variable to be reloaded, and old terminal sessions will not automatically pick up the new command.
A macOS app launched from Finder cannot inherit the PATH environment variable from the terminal, causing a command not found error when invoking CLIs such as claude.
After installing Node, it is recommended to restart the terminal or computer to refresh the PATH environment variable; otherwise, commands such as node and npx may not be found.
A global npm install (`-g`) downloads the package to the global node_modules directory and creates an executable entry in Node's bin directory, which is in PATH by default; terminals that are already open will not pick up PATH changes, so the terminal needs to be reopened.
When the operating system looks up an executable file, it searches one by one through the directories listed in PATH in order; putting . into PATH causes the system to preferentially look for a program with the same name in the current directory, and an attacker can place a malicious executable with the same name (such as ls, git, python) to execute malicious code; this type of attack was historically called "current directory hijacking".
The contents of the PATH environment variable, when read by a system call (such as execvp), do not go through the shell's expansion process, so a ~ in PATH is treated as an ordinary character-based directory.
10 more timeline events
All Facts (20)
Checking "Add to PATH" during Node.js installation automatically adds the installation path to the system environment variable PATH, allowing the system to recognize the node and npm commands from any location.
75%VerifiedA global npm install (`-g`) downloads the package to the global node_modules directory and creates an executable entry in Node's bin directory, which is in PATH by default; terminals that are already open will not pick up PATH changes, so the terminal needs to be reopened.
65%VerifiedPATH is an environment variable in operating systems that tells the system which directories to search for executable programs.
65%VerifiedWhen installing Python, the "Add Python to PATH" checkbox must be checked; otherwise, the command line will not recognize Python.
65%UnverifiedOn some systems automatically adding PATH may affect other Python environments, and if problems occur it can be configured manually.
50%UnverifiedIf the bin directory of a globally installed npm package is not in the system PATH, a "command not found" message may still appear even after a successful installation.
50%UnverifiedIf `node -v` shows "is not recognized as an internal or external command", it is usually because the installation path was not added to the system environment variables, and you need to reinstall or manually configure the PATH.
50%UnverifiedIf the terminal reports 'command not found' after installing Gemini CLI, it usually means its installation directory is not in PATH, or the Node version does not meet the requirements.
50%UnverifiedAfter installation, you need to close the current terminal and reopen it, because globally installed executables require the PATH environment variable to be reloaded, and old terminal sessions will not automatically pick up the new command.
50%UnverifiedA macOS app launched from Finder cannot inherit the PATH environment variable from the terminal, causing a command not found error when invoking CLIs such as claude.
50%UnverifiedAfter installing Node, it is recommended to restart the terminal or computer to refresh the PATH environment variable; otherwise, commands such as node and npx may not be found.
50%UnverifiedPATH should contain only explicit absolute paths; $HOME expands to an absolute path, which meets the requirement, while whether ~ is expanded depends on who parses it and is full of uncertainty.
50%UnverifiedThe root cause of ~ sometimes working and sometimes failing in PATH is that it can only be expanded when some intermediate link happens to invoke the shell to handle it.
50%UnverifiedWhen adding an executable directory under the home directory to PATH, one should use $HOME rather than ~, written as export PATH="$HOME/bin:$PATH".
50%UnverifiedThe contents of the PATH environment variable, when read by a system call (such as execvp), do not go through the shell's expansion process, so a ~ in PATH is treated as an ordinary character-based directory.
50%UnverifiedOne should avoid using the form export PATH="~/bin:$PATH", because ~ will not be expanded by system calls.
50%UnverifiedPlacing relative paths (such as . or ./bin) in PATH brings security risks: when executing commands in an untrusted directory, a malicious program with the same name may be run unexpectedly.
50%UnverifiedWhen the operating system looks up an executable file, it searches one by one through the directories listed in PATH in order; putting . into PATH causes the system to preferentially look for a program with the same name in the current directory, and an attacker can place a malicious executable with the same name (such as ls, git, python) to execute malicious code; this type of attack was historically called "current directory hijacking".
50%UnverifiedAdding the Ollama installation directory to the system PATH environment variable allows the ollama command to be invoked globally from any location.
50%UnverifiedIf the command does not take effect after configuring the environment variable, it may be due to caching, and restarting the computer can resolve the issue.
50%