Installing pyenv on macOS
While installing NPM packages, there might be dependency on python. The node-gyp package requires python to be available in PATH and can't access python3 even if it is available.
To make this work, use Python environments. Install everything using Homebrew.
brew install node
brew install pyenv
pyenv install 3.10.3
pyenv global 3.10.3
echo "export PATH=\"\${HOME}/.pyenv/shims:\${PATH}\"" >> ~/.zshrc
Here we do the following:
- install NodeJS
- install pyenv to manage Python environments
- install recent Python version
- make this version globally available
- adding pyenv to global PATH
Then we can safely run and it should pass
npm install