Table of Contents
We will discuss how to install npm on Ubuntu 16.04 today. Npm is a JavaScript package manager that helps you manage dependencies in your projects and install, share, and distribute programs. It is completely developed in JavaScript, drawing inspiration from other comparable projects such as CPAN for Perl or PEAR for PHP. It’s simple to install npm on Ubuntu 16.04; just follow the instructions below, and in less than ten minutes, npm should be up and running on Ubuntu 16.04.
1. Connect via SSH and Upgrade your System
The very first thing you need to do, before installing npm is to connect to your Linux VPS via SSH and upgrade your system software to the latest version available. You can do that by executing the following command:
sudo apt-get update && sudo apt-get -y upgrade
2. Install Node.js Version – 4.x
npm is bundled with Node.js, so to install npm you only need to install Node.js on your Ubuntu VPS. To install Node.js 4.x LTS on Ubuntu 16.04, run the following commands:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs
3. Install Node.js Version – 7.x
Alternatively, to install Node.js 7.x on Ubuntu 16.04, which is the current version of Node.js, run the commands below:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - sudo apt-get install -y nodejs
4. Verify npm Installation on your Ubuntu 16.04 server
To verify that the installation of npm on Ubuntu 16.04 is successful, check the npm version with the following command:
npm -v
# npm -v
4.2.0
5. Check the npm Help Documentation
A good way to start using npm is to read the npm help page or the npm documentation. To check the npm help page, enter the following command:
npm help
Here is the npm help page:
# npm help
Usage: npm <command>
where <command> is one of:
access, add-user, adduser, apihelp, author, bin, bugs, c,
cache, completion, config, ddp, dedupe, deprecate, dist-tag, dist-tags,
docs, edit, explore, faq, find, find-dupes, get,
help, help-search, home, i, info, init, install, issues, la, link, list, ll, ln, login, logout, ls, outdated, owner,
pack, ping, prefix, prune, publish, r, rb, rebuild, remove, repo, restart, rm, root, run-script, s, se, search, set, show, shrinkwrap, star, stars, start, stop, t, tag, team, test, tst, un, uninstall, unlink, unpublish, unstar, up, update, upgrade, v, version, view, whoami
npm -h quick help on
npm -l display full usage info
npm faq commonly asked questions
npm help search for help on
npm help npm involved overview
Specify configs in the ini-formatted file:
/root/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
[email protected] /usr/lib/node_modules/npm <command>
Using the commands “npm -l” and “npm faq” will give most new users the basic knowledge they need to start using npm. And that’s all that’s needed for installation – you have now successfully installed npm on Ubuntu 16.04. The npm documentation is available at https://docs.npmjs.com/.