mac中node的更新操作

1.先执行操作检查node版本

appledeMacBook-Pro:~ Murphy$ node -v
v10.16.0

2.清除node.js的cache

appledeMacBook-Pro:~ Murphy$ sudo npm cache clean -f
//别忘了输入密码
Password:
//出来这句话的时候,我还以为失败了,这个只是npm对于我们操作的一个警告,别慌
npm WARN using --force I sure hope you know what you are doing.

3.接下来安装最新版本的node

appledeMacBook-Pro:~ Murphy$ sudo npm install -g n
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ n@6.4.0
added 1 package from 4 contributors in 1.969s
appledeMacBook-Pro:~ Murphy$ sudo n stable

  installing : node-v12.16.1
       mkdir : /usr/local/n/versions/node/12.16.1
       fetch : https://nodejs.org/dist/v12.16.1/node-v12.16.1-darwin-x64.tar.xz
   installed : v12.16.1 (with npm 6.13.4)

4.重新检查一下node版本

appledeMacBook-Pro:~ Murphy$ node -v
v12.16.1
appledeMacBook-Pro:~ Murphy$ 

你可能感兴趣的:(Node.js,node.js)