Install Npm In A Few Easy Steps | CSS-Tricks (2024)

DigitalOcean provides cloud products for every stage of your journey. Get started with $200 in free credit!

Feel like you have a pretty good idea of what a package manager is? We’ve certainly covered a lot of ground getting familiar with all the terms and concepts of package managers, but I’d say it’s high time we actually do something with our newfound knowledge. But first, we need to install npm.

To that end, we’re going to make sure we have Node and npm installed, then make a little sample project to give you real hands-on experience working with the npm basics and what it looks like to use npm in your front-end development workflow.

Guide chapters

  1. Who the Heck is This Guide For?
  2. What the Heck Does “npm” Mean?
  3. What the Heck is the Command Line?
  4. What the Heck is Node?
  5. What the Heck is a Package Manager?
  6. How the Heck Do You Install npm? (You are here!)
  7. How the Heck Do You Install npm Packages?
  8. What the Heck Are npm Commands?
  9. How the Heck Do You Install an Existing npm Project?

Confirm whether npm is already installed

Before installing npm, we should confirm whether it’s already installed! If you’re unsure whether or not npm is already installed on your system, open your terminal of choice, whether it’s the Terminal app in MacOS, the integrated terminal in a code editor like VS Code, or some other terminal where you have access to the command line.

Ready? Start with this command (notice we’re not including the $ character in these examples):

node -v

That command displays the current version of Node—that is, if it is installed. If Node is installed, the command line will respond with the Node version number that is currently installed:

v16.9.1

Your version may be different, of course. Either way, the fact that you see a version number confirms that npm is installed on your system! Let me stress that the numbers themselves are unimportant, just as long as we get some version number.

If npm or Node is not currently installed, you’ll see a message along the lines of “Command not found” instead. In the unlikely event that npm is installed but Node is not (or vice versa), then it’s probably worth uninstalling it before continuing.

Assuming you do need to install npm and Node (and if you don’t, you’re welcome to skip ahead to the next section), we’re going to take the advice of the official NPM directions and do so via a program called nvm.

Installing Node Version Manager

Node Version Manager, or nvm, allows you to install, update, and uninstall Node on your system, and also to manage multiple versions of Node that you can switch between.

Install Npm In A Few Easy Steps | CSS-Tricks (1)

As you may know, server-side languages have their own release versions, e.g., Node 17.1.0, rather than being tied to browser versions, such as Chrome 96. We won’t need any version of Node but the latest, so this won’t be necessary for us right now, although it may be advantageous for you down the road.

I know, it may seem like a lot of extra work to install one program just to install another, but again, this is the recommended path, and doing things the right way from the start makes them much easier in the long run. I’d rather set you up for success than make things briefly easier at the expense of more complexity later.

Installing nvm on Windows

If you’re on Windows, you’ll actually have an easier time here. You’ll need nvm for Windows specifically, but luckily, Windows already has an installer you simply download and run. The directions are in the NVM for Windows repo over at GitHub.

  • Download the latest version of NVM for Windows. It can be installed manually, if you prefer.
  • Open the terminal and run the nvm list available command to see a list of Node versions that are available to download and install.
  • Run the nvm use command, followed by the version number of Node you want to use (e.g. nvm use 16.9.1) to use a specific version. Alternatively, you can use use latest, lts, or newest instead of a specific version number, where newest is the latest installed version.

Once it’s installed, nvm will work the same way on your Windows machine as it does on any other system.

Installing nvm on MacOS

To install nvm on MacOS, the first step is to download it with this command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

0.39.0 is the latest version at publish time, but it may be worth checking the nvm installation readme and getting the latest, if different.

Once you’ve pasted that command into the terminal and hit Enter, you’ll see your terminal output a bunch of stuff that doesn’t really matter. In fact, I’ll let you in on a little secret: nobody reads the things in their terminals most of the time. All we care about is that…

  1. the command eventually finishes; and
  2. it doesn’t end with an error message.

If you are prompted for a command in the middle of the installation, hit the q key to quit and continue.

You’ll know the command is finished running when the typing cursor starts blinking again, indicating the terminal is waiting for your typed input. You might even see this right after nvm has completed installing:

=> Close and reopen your terminal to start using nvm or run the following to use it now:

Assuming you see no errors at this point, I would recommend the simpler option of quitting and restarting whatever terminal app you’re using before moving on. It’s a nice way to make sure you’re working with a clean slate.

How to install npm via Node

Now that nvm is installed, we’re ready to do what we really wanted to do in the first place: install npm and Node on our system.

It’s not a bad idea to confirm nvm is installed properly, by running nvm -v. If the terminal shows you the installed version number, you’re good to go! If not, remember that you might have to restart your terminal app before the installation fully processes.

Now that we have nvm, installing Node is a super short command:

nvm install node

Simple enough, eh?

You should see a message along the lines of Downloading and installing node v17.1.0, though the version number may not match, which is fine. You’ll get whatever the latest stable version is at runtime. Wait until the command has finished running—again, you’ll know it’s done once you are back at the default prompt and you’re able to type more commands.

After that, you’re all done here! That simple command not only installs Node, but it will install npm as well. Again, you can verify everything is installed and up to date with npm -v and node -v. If all is good, you’ll get a version number.

What’s next

Alright, at this point, we have nvm for installing and managing Node, Node itself, and npm for handling Node packages. Next up in this npm guide, we’re going to install some packages into a project!

← Chapter 5

Chapter 7 →

Install Npm In A Few Easy Steps | CSS-Tricks (2024)
Top Articles
Lesson 6: Incentives, Innovations, and Roles of Institutions - Foundation For Teaching Economics
Master Google Advanced Image Search: Tips and Tricks
Omega Pizza-Roast Beef -Seafood Middleton Menu
Metra Union Pacific West Schedule
Mileage To Walmart
Beds From Rent-A-Center
Daniela Antury Telegram
2021 Lexus IS for sale - Richardson, TX - craigslist
Inside California's brutal underground market for puppies: Neglected dogs, deceived owners, big profits
8 Ways to Make a Friend Feel Special on Valentine's Day
Ivegore Machete Mutolation
Craigslist Pets Longview Tx
Pittsburgh Ultra Advanced Stain And Sealant Color Chart
Procore Championship 2024 - PGA TOUR Golf Leaderboard | ESPN
Las 12 mejores subastas de carros en Los Ángeles, California - Gossip Vehiculos
U Arizona Phonebook
Kayky Fifa 22 Potential
Gayla Glenn Harris County Texas Update
Quest: Broken Home | Sal's Realm of RuneScape
Food Universe Near Me Circular
Buying Cars from Craigslist: Tips for a Safe and Smart Purchase
Engineering Beauties Chapter 1
Globle Answer March 1 2023
Avatar: The Way Of Water Showtimes Near Maya Pittsburg Cinemas
Tokyo Spa Memphis Reviews
Geico Car Insurance Review 2024
Shelby Star Jail Log
Fuse Box Diagram Honda Accord (2013-2017)
Craftsman Yt3000 Oil Capacity
Free Tiktok Likes Compara Smm
Angel del Villar Net Worth | Wife
The Hoplite Revolution and the Rise of the Polis
Shiftwizard Login Johnston
Federal Student Aid
Indiana Wesleyan Transcripts
Hotels Near New Life Plastic Surgery
Weapons Storehouse Nyt Crossword
Scanning the Airwaves
Bismarck Mandan Mugshots
How To Paint Dinos In Ark
Crazy Balls 3D Racing . Online Games . BrightestGames.com
O'reilly's Palmyra Missouri
Post A Bid Monticello Mn
How Big Is 776 000 Acres On A Map
Sound Of Freedom Showtimes Near Amc Mountainside 10
Stitch And Angel Tattoo Black And White
Best Restaurant In Glendale Az
Doelpuntenteller Robert Mühren eindigt op 38: "Afsluiten in stijl toch?"
Oak Hill, Blue Owl Lead Record Finastra Private Credit Loan
7 Sites to Identify the Owner of a Phone Number
Honeybee: Classification, Morphology, Types, and Lifecycle
Latest Posts
Article information

Author: Jerrold Considine

Last Updated:

Views: 5811

Rating: 4.8 / 5 (78 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Jerrold Considine

Birthday: 1993-11-03

Address: Suite 447 3463 Marybelle Circles, New Marlin, AL 20765

Phone: +5816749283868

Job: Sales Executive

Hobby: Air sports, Sand art, Electronics, LARPing, Baseball, Book restoration, Puzzles

Introduction: My name is Jerrold Considine, I am a combative, cheerful, encouraging, happy, enthusiastic, funny, kind person who loves writing and wants to share my knowledge and understanding with you.