How to set up a new npm account & install npm
In the previous tutorial we showed you how to search and select packages. The current tutorial will walk you through the process of setting up your own npm account, as well as, how you can install npm to your system.
We will be dividing the tutorial into three:
- Create an account from npmjs.com.
- Install npm from a terminal console.
- Login to the terminal with your new username.
It should be noted that many of the steps that you perform on the website (recall from the previous tutorial) can be performed directly from the Command Line Interface.
A. Create an account
- To create an account, you need to go to http://www.npmjs.com and click on sign up.
- The next to you need to do is to complete the form on the sign up page
- Your Full Name: First and last name. (You can also enter middle name(s)).
- Your Public Email: Enter an email address. This email address is added to the package metadata when you publish a package. This implies that the email address can be discovered by anyone who downloads your packages. Additionally, npm sends email to this account when you update packages, npm will also send occasional product updates and information.
- Your Username: Enter the username that will be shown when you publish packages or when you interact with other users within npm. You have to choose a name that doesn't violate our policy guidelines. The name has to be lower case. You can add dashes and numerals, but there are restrictions in so as to prevent fake accounts.
- Your Password: you should choose a password that meets our password requirements. Your password has to be longer than 7 characters, must not match or significantly contain your username, and must not be a member of this list of common passwords or the "Have I Been Pwned" breach database.
Verify your email address
Note: you have to verify your email address before you can publish packages to the npm registry.
- Log into the email address that you used to sign up for an npm user account
- you should see an email titled welcome to npm (you should search All mail in case the email doesn?t appear in the inbox)
- click on the link in your email. Success! This will redirect you to your new landing page. Which should be something like: https://www.npmjs.com/~yourusername
There are links to many useful resources in this message; you might want to flag it for future reference.
However, if you don't fine the welcome message, you should click on resend:
After you set up your Login Account
Now you have a login account. Below are some of the things that you can do before (or after) you install npm:
- You can edit your Profile
- You can set up Two-Factor Authentication
- You can create an Organization, Add Members, and Form Teams
- You can learn about Paid Accounts and Billing
Alternatively, you can install npm in the terminal console, as will be explained soon, then come back to perform these steps.
Below is where you can edit your profile and get started:
Terminals, Editors, and Git (for Beginners)
You can skip this section if you have worked with terminals or editors in the past.
- You should find the terminal emulator for your computer
- Go to https://support.apple.com/guide/terminal/welcome/mac if you are using Apple terminal
- Go to https://docs.microsoft.com/en-us/powershell if you are using Windows PowerShell
- Go to https://opensource.com/life/17/10/top-terminal-emulators if you are using Linux terminal emulators
B. Install npm & manage npm versions
Because npm was written in Node.js, you need to install Node.js to use npm. Npm can be installed from the Node.js website or by installing a Node Version Manager (NVM).
If you just need to get started exploring npm, the fastest method is using the Node.js installation. If you are an advanced developer who is ready to jump in and work with versions, you can use the node version manager.
Installing npm from the Node.js site
- Install Node.js & npm
OS/X or Windows
If you are using OS X or Windows, you should use one of the installers from the Node.js download page. Make sure you install the version labeled LTS. The other versions have not yet been tested with npm.
If you are using Linux, you should choose one of these options:
- click https://nodejs.org/en/download/package-manager/ to install npm for Linux in the way many Linux developers prefer.
- scroll through the installers on https://nodejs.org/en/download/
- check https://github.com/nodesource/distributions to see if there's a more recent version that works with your system.
Less-common operating systems
Click https://nodejs.org/en/download/package-manager/ to learn about installing node.js for a variety of operating systems.
Once you are done installing, you should run node -v. The current version should be v8.9.1 or higher.
When node.js is installed, npm will automatically be installed. However, npm will be updated more frequently than Node.js, so ensure that you have the latest version.
To test, you should run npm -v.
To ensure that you have the latest version run npm install npm@latest -g.
Using a version manager to install Node.js and npm
Because npm and node.js products are managed by different entities, its updates and maintenance can become complex. Additionally, the Node.js installation process will install npm in a directory that only has local permissions. This may cause permissions errors when you attempt to run packages globally.
In order to solve both issues, most developers opt to use a node version manager, or nvm, when installing npm. The version manager avoids permissions errors, and solves the complexities of updating Node.js and npm.
Additionally, developers can utilize an nvm to test their applications on multiple versions of npm. The nvm will enable you to easily switch npm as well as node versions. This will make it easier to ensure that your applications work for most users, even when they are using other versions of npm. If you want to install a version manager, you should use the instructions for the version manager you select to learn how to switch versions, and also to learn how to keep up-to-date with the latest version of npm.
Click https://github.com/creationix/nvm/blob/master/README.md#installation to learn how to install nvm for MacOs.
To install and manage npm and Node.js on Windows, we suggest that you use nvm-windows
Click https://github.com/creationix/nvm/blob/master/README.md#installation to learn how to install nvm for Linux.
C. Login to npm from a terminal
If you want to test your new account, type: npm login
It will prompt you for your username, password, and email. Ensure that you spell your username exactly the same way as you entered it on the website, or it will create a new account.
If two-factor authentication is already set up for your account, you are going to be asked for a one-time password, whenever you are login.
If you want to test that you have successfully logged in, you should type npm whoami.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join