Article directory
1. Error zsh: command not found: npm
According to the prompt: zsh: command not found: npm. It means that the npm command was not found, which means there are two situations:
one is: you do not have the environment to install nodejs at all; the other is that the environment variables are not configured, or the configuration is incorrect.
2. Solution
In this case, you need to check the nodejs environment first. Execute the following command:
brew info node@10
Check the version of nodejs in your homebrew. If Not installed appears, it means it is not installed.
You can execute the following commands:
brew install node@10
After waiting for the installation to complete, execute npm -v to see if there are still errors.
moon@moondeiMac % npm -v
zsh: command not found: npm
Execute the following code to add environment variables to the system:
echo 'export PATH="/usr/local/opt/node@10/bin:$PATH"' >> ~/.zshrc
and then execute
source $HOME/.bashrc
source ~/.zshrc
source $HOME/.zshrc
If you execute npm -v again, the error will no longer be reported.