npm is bundled with Node.js, so if you install Node.js you'll automatically have
npm installed too. You can choose between a Current and a LTS version
For Microsoft Windows you can download a MSI installer from https://nodejs.org/en/download/.
For Apple OS X you can download a PKG installer from the same location https://nodejs.org/en/download/.
For Linux you can use your package manager to install Node.js and npm.
You can also compile Node.js from source and you'll still get
npm. There is also a script you can run which will install
curl -L https://www.npmjs.com/install.sh | sh
The recommended method of updating your
npm installation is to simply have
npm install itself:
npm install -g npm@latest
You can alternatively upgrade to the current LTS version rather than the latest version:
npm install -g npm@lts
You can also install any version of Node (and npm) with
nvm. When installing globally with
npm with an
nvm installation, you do not need to use
sudo (or Run as Administrator on Windows).