Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to install npm

This guide shows you how to install npm, a tool that downloads code packages for JavaScript projects.

Databases2 min read10 steps

What is npm?

JavaScript is a language used to build websites and apps. Many developers share ready-made pieces of code. These pieces are called packages. npm is the tool that finds and installs those packages for you. It is like an app store for code.

npm comes together with Node.js. Node.js lets JavaScript run on a server, not just in a browser. When you install Node.js, you get npm too.

Install on Windows or Mac

  1. Open the official Node.js website in your browser.
  2. Download the version marked LTS. LTS means long-term support. It is the steady, safe choice.
  3. Open the downloaded file.
  4. Follow the installer. Accept the default options.
  5. Restart your terminal. A terminal is a window where you type commands.

Install on Ubuntu or Debian Linux

You need root access for this, so it fits VPS and dedicated server customers.

  1. Log in with SSH. SSH is a safe way to type commands on a remote server.
  2. Update the package list:
    sudo apt update
  3. Install Node.js and npm:
    sudo apt install nodejs npm
    This installs both tools from the system's software list.

On CentOS, AlmaLinux or Rocky Linux, use sudo yum install nodejs npm or sudo dnf install nodejs npm.

The version in the system list can be old. For a newer one, use the NodeSource instructions or nvm, a tool that installs many Node versions. Look for their official guides.

Check that it works

  1. Type:
    node -v
    This shows the Node.js version.
  2. Type:
    npm -v
    This shows the npm version.

If both print numbers, you are ready.

Try it out

npm install express

This downloads a package named express into a folder called node_modules in your current folder.

Warning: Avoid using sudo with npm install for normal projects. It can cause permission problems.

Tip: Shared hosting may not offer Node.js. Ask Hostvento support whether your plan supports it. You can open a ticket.

Quick recap

  • npm installs code packages for JavaScript.
  • It arrives together with Node.js.
  • Use the installer on Windows and Mac, or apt install on Ubuntu.
  • Check with node -v and npm -v.