Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

Costas Zarifis

Tutorials, code snippets, hacks and more...

Installing NodeJS, npm and bower

Node Image

In this guide I will be showing you how to install NodeJS (and its package managers npm and bower) on your machine.

If you're on a Linux machine, run the following commands:

sudo apt-get update
sudo apt-get install nodejs

If you're using a Mac or windows just head over to this link and download the appropriate installer. Then follow the wizard to install it successfully.

When you're done with the installation, open a new terminal and run the following command:

node -v

if that doesn't work, (which is probably the case if you're on linux) do:

nodejs -v

If you get something like this:


You've successfully installed NodeJS!

If the "node -v" command didn't work but the nodejs -v command worked it might be a good idea to create a bash alias that maps node to nodejs for consistency purposes. If however your machine has multiple users and all of them need access to node, you might be better off creating a symbolic link. Not as clean but, Oh well... It's good enough.

To do that, run the following command:

which nodejs

The result will be something like this:


Next step is to copy it and create a link to it like this:

sudo ln -s /usr/bin/nodejs /usr/bin/node

Ok, that should do it! If you open a new terminal and run the command:

node -v

You should be seeing the NodeJS version that is installed on your system.

If you've made it here, congrats! We've successfully installed NodeJS. However we're not done just yet. Most applications and frameworks have a certain number of dependencies to third party libraries. In order to install all these libraries for a Node based application you will probably need either bower or npm (or both). These are simply package managers, so let's go ahead and install them:

For linux do:

sudo apt-get install npm

If you're using a Mac chances are that npm was already installed when you ran the installer for node.

In any case the best way to test it is to open a terminal and run


If you're seeing something like the following:

Usage: npm <command>

where <command> is one of:
    add-user, adduser, apihelp, author, bin, bugs, c, cache,
    completion, config, ddp, dedupe, deprecate, docs, edit,
    explore, faq, find, find-dupes, get, help, help-search,
    home, i, info, init, install, isntall, issues, la, link,
    list, ll, ln, login, ls, outdated, owner, pack, prefix,
    prune, publish, r, rb, rebuild, remove, repo, restart, rm,
    root, run-script, s, se, search, set, show, shrinkwrap,
    star, stars, start, stop, submodule, tag, test, tst, un,
    uninstall, unlink, unpublish, unstar, up, update, v,
    version, view, whoami

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm faq          commonly asked questions
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@1.3.10 /usr/share/npm

You're good to go!

OK, now for bower you can just use the following command:

sudo npm install -g bower

And we're done! Thanks for reading!

About the author

Costas Zarifis


comments powered by Disqus