如何在mac中升级节点版本?

时间:2018-06-06 04:20:10

标签: node.js

我想在mac上将我的节点版本从mapView.getOverlays().add(0,OverlayEvents); mapView.getOverlays().remove(0); 升级到v6.2.1。我一直在寻找一些解决方案Upgrade NodeJS to the latest version on Mac os并尝试过。

我试过了:

v8.11.2

当我输入sudo npm cache clean -f (force) clear you npm cache sudo npm install -g n install "n" (this might take a while) sudo n stable upgrade to lastest version 时,它仍会显示v6.2.1

node -v

然后我尝试了:

motogod19de-MacBook-Pro:~ motogod19$ sudo npm cache clean -f
Password:
npm WARN using --force I sure hope you know what you are doing.
motogod19de-MacBook-Pro:~ motogod19$ npm install -g n
/Users/motogod19/.nvm/versions/node/v6.2.1/bin/n -> /Users/motogod19/.nvm/versions/node/v6.2.1/lib/node_modules/n/bin/n
+ n@2.1.11
added 1 package from 4 contributors in 0.894s
motogod19de-MacBook-Pro:~ motogod19$ sudo n stable

     install : node-v10.2.1
       mkdir : /usr/local/n/versions/node/10.2.1
       fetch : https://nodejs.org/dist/v10.2.1/node-v10.2.1-darwin-x64.tar.gz
######################################################################## 100.0%
   installed : v6.2.1

motogod19de-MacBook-Pro:~ motogod19$ node -v
v6.2.1

最后仍显示brew update brew upgrade node npm install -g npm

v6.2.1

他们不适合我的情况......

我的mac版本:

motogod19de-MacBook-Pro:~ motogod19$ node -v
v6.2.1
motogod19de-MacBook-Pro:~ motogod19$ brew upgrade node
Error: node 10.3.0 already installed
motogod19de-MacBook-Pro:~ motogod19$ npm install -g npm
/Users/motogod19/.nvm/versions/node/v6.2.1/bin/npm -> /Users/motogod19/.nvm/versions/node/v6.2.1/lib/node_modules/npm/bin/npm-cli.js
/Users/motogod19/.nvm/versions/node/v6.2.1/bin/npx -> /Users/motogod19/.nvm/versions/node/v6.2.1/lib/node_modules/npm/bin/npx-cli.js
+ npm@6.1.0
updated 2 packages in 11.901s
motogod19de-MacBook-Pro:~ motogod19$ node -v
v6.2.1

有人知道我应该尝试什么吗? 任何帮助,将不胜感激。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

sudo npm cache clean -f
sudo npm install -g n
sudo n versionNumber (i.e 14.16.0)

我试过了,它工作正常