Mac电脑如何升级node.js
一 、mac可以用node.js的多版本管理器n来升级和切换
mac可以用node.js的多版本管理器n来升级和切换,命令如下:
- sudo npm cache clean -f //清除node.js的cache
Last login: Sat Nov 2 12:39:55 on console
beiluo@beiluodeMBP ~ % sudo npm cache clean -f
Password:
npm warn using --force Recommended protections disabled.
- sudo npm install -g n //使用npm安装n模块
beiluo@beiluodeMBP ~ % sudo npm install -g n
changed 1 package in 655ms
- npm view node versions // 查看node所有版本 ,
如果遇到报错,就是权限不够 ,加sudo 命令
beiluo@beiluodeMBP ~ % npm view node versions
npm error code EACCES
npm error syscall open
npm error path /Users/beiluo/.npm/_cacache/tmp/1ea86a7c
npm error errno EACCES
npm error
npm error Your cache folder contains root-owned files, due to a bug in
npm error previous versions of npm which has since been addressed.
npm error
npm error To permanently fix this problem, please run:
npm error sudo chown -R 501:20 "/Users/beiluo/.npm"
npm error A complete log of this run can be found in: /Users/beiluo/.npm/_logs/2024-11-02T13_55_50_158Z-debug-0.log
sudo npm view node versions
beiluo@beiluodeMBP ~ % sudo npm view node versions
[
'0.0.0', '0.1.14', '0.1.15', '0.1.16', '0.1.17', '0.1.18',
'0.1.19', '0.1.20', '0.1.21', '0.1.22', '0.1.23', '0.1.24',
'0.1.25', '0.1.26', '0.1.27', '0.1.28', '0.1.29', '0.1.30',
'0.1.31', '0.1.32', '0.1.33', '0.1.90', '0.1.91', '0.1.92',
'0.1.93', '0.1.94', '0.1.95', '0.1.96', '0.1.97', '0.1.98',
'0.1.99', '0.1.100', '0.1.101', '0.1.102', '0.1.103', '0.1.104',
'0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5',
'0.2.6', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4',
'0.3.5', '0.3.6', '0.3.7', '0.3.8', '0.4.0', '0.4.1',
'0.4.2', '0.4.3', '0.4.4', '0.4.5', '0.4.6', '0.4.7',
'0.4.8', '0.4.9', '0.4.10', '0.4.11', '0.4.12', '0.5.0',
'0.5.1', '0.5.2', '0.5.3', '0.5.4', '0.5.5', '0.5.6',
'0.5.7', '0.5.8', '0.5.9', '0.5.10', '0.6.0', '0.6.1',
'0.6.2', '0.6.3', '0.6.4', '0.6.5', '0.6.6', '0.6.7',
'0.6.8', '0.6.9', '0.6.10', '0.6.11', '0.6.12', '0.6.13',
'0.6.14', '0.6.15', '0.6.16', '0.6.17', '0.6.18', '0.6.19',
'0.6.20', '0.6.21', '0.7.0', '0.7.1', '0.7.2', '0.7.3',
'0.7.4', '0.7.5', '0.7.6', '0.7.7', '0.7.8', '0.7.9',
'0.7.10', '0.7.11', '0.7.12', '0.8.0', '0.8.1', '0.8.2',
'0.8.3', '0.8.4', '0.8.5', '0.8.6',