Reputation: 274
I wanted to create a react project and when I executed the command it said zsh: command not found: npx
Then I tried the ls
command and it said zsh: command not found: ls
.
After setting the export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
command both the ls
and npx create-react-app
command worked fine and when close the terminal and reopen again, the same command not found
error shows.
Is there any permenent fix without setting export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
command
Upvotes: 2
Views: 30125
Reputation: 131
This is what worked for me on macOS Monterey,
Although I added the path to ./zshrc and sourced the file, after reopening the terminal the PATH was not exported
I followed these steps to solve this
.zprofile
with touch .zprofile
at the home directory. If the file already exists use that.export PATH=${PATH}:/Users/Development/HashBaze/flutter/bin
.zprofile
and .zshrc
after following the above two steps.This solution worked for me on macOS Monterey version 12.5
Upvotes: 1
Reputation: 157
For adding the variables to the path you need to add it to zshrc file for making that variable available locally.
The way you have used will only work until you use it in the same terminal window path only.
To solve the problem, follow these steps:
Goto you home directory
Simultaneously press cmd + shift + (.) Note:the last key is the key of dot
On following step 2, new hidden files will appear in home directory, look for (.zshrc) file and open it using any text editor.
Add your path variable in it, save and then close it.
Example: export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Open terminal and run the command: "echo $PATH" and see if your added variable is present in the output shown by terminal.
If yes, You are now ready to go to use it from anywhere in terminal now.
Upvotes: 7