Coolest Guides on the Planet

coolest guides on the planet

Coolest Guides On The Planet

Neil Gee

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

Installing node.js on macOS Mojave, macOS Sierra and earlier OSX

September 28, 2018 24 Comments

node.js allows you to run javascript in the Terminal as appose to a regular browser which makes for a modern workflow in web development, with both node.js installed and a package manager called npm (Node Package Manager) also installed, which can manage other packages that work with node.js, one of the main ones being gulp.js for a web development workflow.

To install node.js on macOS Mojave, Sierra  (and earner OSX versions)  you can download a pre-compiled binary package which makes a nice and easy installation. Head over to http://nodejs.org/ and click the install button to download the latest package. Either version is Ok, if you are new to it best to use the recommended version.

 

 

Install the package from the .dmg by following along the install wizard which will install both node and npm, npm is Node Package Manager which allows for installs of additional packages for node.js.

 

At the end of the install you are prompted to make sure that /usr/local/bin is in your path, double check you have it by running in the Terminal:

echo $PATH

If not add it in either .bash_profile or .bashrc in your home directory.

After install check it was ok by entering in the command line node which will open a node javascript session:

node

> console.log('hello node');

hello node

undefined

>

To exit the node.js session just hit ‘control’ + ‘c’ twice.

If you have an earlier version of node you can just download the latest version and install to upgrade it and it will over write the previous version.

To check your version of node run …

node -v

Installing Packages for Node

There are many packages for Node such as the popular gulp.js,  you use the command npm to see a complete list run:

npm search

This will return an exhaustive list of available packages, to install a package run npm install

npm install easyimage

To list installed packages run

npm ls

To upgrade npm packages

npm update

To sudo or not to sudo

It is cleaner not to use sudo when installing npm packages there are a couple of options here on how this is done.

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

Updating NodeJS

To upgrade node.js itself on macOS just download and install the latest from nodejs.org – this will simply override the previous version and keep all your packages that have been already installed.

Share this:

  • Twitter
  • Facebook

Related

Cats: macOS, Open Source

Subscribe

Coolest Guides on the Planet

Tags

3gs 10.6 apache backup baseband Bing boot clean urls Coolest Guy on the Planet cpanel css custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect remote rsa SEO shell ssh terminal unstoppables urls Yahoo
Get DesktopServer

Donate a Beer to the Coolest Guides

Beaver Builder Ultimate Addons

Copyright © 2019· Neil Gee - All Rights Reserved - Hosted by Cloudways and Vultr