Switch python/ node in mac

node switch

when npm install error happen
check whether the web problem or the node version problem.

1
2
3
4
5
6
7
8
9
10
11
12
13
node --version
npm cache clean -f
npm install -g n

# switch
n
# delete
n rm

# node version
n latest
n stable
n lts

https://stackoverflow.com/questions/32791657/node-gyp-rebuild-build-error-make-failed-npm-install
https://segmentfault.com/q/1010000009734734
https://blog.csdn.net/weixin_38190050/article/details/99644735

install python3

brew install python3

path in different way

origin path
default(2.7) /System/Library/Frameworks/Python.framework/Versions/2.7
brew(2.7/3.x) /usr/local/Cellar/python
pkg(3.x) /Library/Frameworks/Python.framework/Versions/3.x

enviroment setting

vi ~/.bash_profile

1
2
3
4
5
6
7
# Setting PATH for Python 2.7
PATH="/System/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"

# Setting PATH for Python 3.7.6
PATH="/usr/local/Cellar/python/3.7.6_1/bin:${PATH}"

export PATH

vi ~/.bashrc

1
2
3
alias python2='/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7'
alias python3='/usr/local/Cellar/python/3.7.6_1/bin/python3.7'
alias python=python3

source ~/.bash_profile
source ~/.bashrc

https://blog.csdn.net/u014259820/article/details/81023224