Thursday, September 7, 2017

How to update Node.js in Mac

Steps:

1) NPM(Node Package Manager) should have been installed.

2) Current installed version (in my box)
$ node -v
v6.3.0

--------------------------------------------------

3) Upgrade to Stable version.
Run the following command.

$ sudo npm cache clean -f

Install package n (node version management)

$ sudo npm install -g n
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ n@2.1.8
added 1 package in 1.535s

$ sudo n stable

     install : node-v8.4.0
       mkdir : /usr/local/n/versions/node/8.4.0
       fetch : https://nodejs.org/dist/v8.4.0/node-v8.4.0-darwin-x64.tar.gz
######################################################################## 100.0%
   installed : v8.4.0

$ node -v
v8.4.0

------------------------------------------

4) Upgrade to latest LTS

Follow the step 3 , however instead of running 'sudo n stable' run the following command : (give the node LTS version name, at this time 6.11.3 is the latest node version)(https://nodejs.org/en/)

$ sudo n 6.11.3

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

$ node -v
v6.11.3

No comments:

Post a Comment