VLT-Website-Heading

Installing npm and Node.js on a Mac OS laptop

Jun 30, 2019 8:47:26 PM / by Vu Long Tran

This is a guide written to describe how to set up and install npm and node.js onto your Mac laptop.

If you are reading this, you are looking to leverage the cool Javascript packages from npm and run these outside of a browser for testing and utilising apps. As you ideally want to test your applications on multiple versions of npm to ensure they work for users on different versions. That is:

  • Node.js is an open-source, cross-platform, JavaScript run-time environment that executes JavaScript code outside of a browser.
  • npm makes it easy for JavaScript developers to share and reuse code, and makes it easy to update the code that you’re sharing, so you can build amazing things.

npm Javascript packages!

How to install npm and Node.js on a Mac OS laptop

1. Install Mac OS installer from Node.js

Visit NodeJS at nodejs.org/en/download/ and install this onto your Mac laptop.

You'll find that npm is installed with Node.js. As npm is distributed with Node.js- which means that when you download Node.js, you automatically get npm installed on your computer.

2. Downloading and installing Node.js and npm

Confirm that it is installed correctly by checking your version of npm and Node.js§.

To see if you already have Node.js and npm installed and check the installed version, run the following commands:

node -v<br>npm -v<br><br><strong>$ node -v</strong><br>v10.16.0<br><br><strong>$ npm -v</strong><br>6.9.2

4. Run this npm install npm@latest -g

npm is a separate project from Node.js. So even if you’ve just downloaded Node.js (which also includes npm), you’ll probably need to update your npm. 

To update your npm, type this into your terminal:

<strong>$ sudo npm install npm@latest -g</strong><br>/usr/local/bin/npm -&gt; /usr/local/lib/node_modules/npm/bin/npm-cli.js<br>/usr/local/bin/npx -&gt; /usr/local/lib/node_modules/npm/bin/npx-cli.js<br>+ npm@6.9.2<br>updated 1 package in 4.132s

5. Run and check npm version

<strong>$ npm - v </strong>or&nbsp;<br><strong>$ npm - version</strong><br><br>Usage: npm &lt;command&gt;<br><br>where &lt;command&gt; is one of:<br>&nbsp;&nbsp;&nbsp;&nbsp;access, adduser, audit, bin, bugs, c, cache, ci, cit,<br>&nbsp;&nbsp;&nbsp;&nbsp;clean-install, clean-install-test, completion, config,<br>&nbsp;&nbsp;&nbsp;&nbsp;create, ddp, dedupe, deprecate, dist-tag, docs, doctor,<br>&nbsp;&nbsp;&nbsp;&nbsp;edit, explore, get, help, help-search, hook, i, init,<br>&nbsp;&nbsp;&nbsp;&nbsp;install, install-ci-test, install-test, it, link, list, ln,<br>&nbsp;&nbsp;&nbsp;&nbsp;login, logout, ls, org, outdated, owner, pack, ping, prefix,<br>&nbsp;&nbsp;&nbsp;&nbsp;profile, prune, publish, rb, rebuild, repo, restart, root,<br>&nbsp;&nbsp;&nbsp;&nbsp;run, run-script, s, se, search, set, shrinkwrap, star,<br>&nbsp;&nbsp;&nbsp;&nbsp;stars, start, stop, t, team, test, token, tst, un,<br>&nbsp;&nbsp;&nbsp;&nbsp;uninstall, unpublish, unstar, up, update, v, version, view,<br>&nbsp;&nbsp;&nbsp;&nbsp;whoami<br><br>npm &lt;command&gt; -h&nbsp; quick help on &lt;command&gt;<br>npm -l&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; display full usage info<br>npm help &lt;term&gt; &nbsp; search for help on &lt;term&gt;<br>npm help npm&nbsp; &nbsp; &nbsp; involved overview<br><br>Specify configs in the ini-formatted file:<br>&nbsp;&nbsp;&nbsp;&nbsp;/Users/vulongtran/.npmrc<br>or on the command line via: npm &lt;command&gt; --key value<br>Config info can be viewed via: npm help config<br><br>npm@6.9.2 /usr/local/lib/node_modules/npm

6. Enjoy using npm and node.js on your Mac laptop!

You should be good to go to enjoy Javascript packages from npm now.

For more details, you can refer to:

Get npm!
Install Node.js, npm, and stay up-to-date. npmjs.com/get-npm

NPM - Downloading and installing Node.js and npm. https://docs.npmjs.com/downloading-and-installing-node-js-and-npm

Topics: tech, apple

Vu Long Tran

Written by Vu Long Tran

Solutions Engineer APAC @pymetrics . ex-@Forrester consultant. Tweeting on #cloud, #cybersecurity, #equality and #tech tinkering!

    Lists by Topic