What is npm?

npm-jokes-1.png

NPM is probably the best known package manager for setting up and running a node.js project. When node.js is installed, npm gets installed with it, so there is no need to install npm separately. NPM sets up the development environment of your project, in our case we are using hardhat as our development environment, and installs important dependencies , which are other pieces of software that are needed to help the core software of the project run. Examples of dependencies are OpenZeppelin/contracts, ethers.js, chai or typescript.

Choose your operating system and setup from the choices below:

Installing node.js and npm with nvm on Windows 10/WSL2

If your operating system is Windows 10 or 11 and you have not installed WSL-2 yet, Microsoft has a pretty good article that can help you install Linux on your Windows machine here: https://docs.microsoft.com/en-us/windows/wsl/install . One minor change to the directions should be to the commands to add a specific distribution. You will want to choose the Ubuntu Linux distribution, so you will want to use the following command when installing WSL with the command line, wsl --install -d Ubuntu-20.04. This will ensure that a long-term supported version of Ubuntu Linux is installed on WSL-2. If you need additional info, you can also refer to the Tooling section of Lesson 2 which gives direction on operating systems, a command line mini-lesson and more.

Let’s get the party started and install npm on WSL2! 🎉

  1. Click on the Windows Start Button, then open Ubuntu 20.04 on Windows.

wsl-s_in_windows_app_list.PNG

  1. We need to install curl into our WSL-2 instance, so type into the command line, sudo apt-get install curl . You may be prompted for a password. It is the same password you created when you first set up WSL-2. You are prompted to use the password because you are using sudo which is “super user permission”. cURL allows us to to download necessary software from outside software library servers.

install-curl.PNG

  1. Next, we want to install Node Version Manager (nvm). NVM is a super helpful tool because it allows you to download and run different versions of npm. In our command line, we need to copy and paste the following command: curl -o- [<https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh>](<https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh>) | bash and hit Enter. Let’s verify that it was installed correctly by typing command -v nvm. This should return nvm if it was installed correctly. If you get an error or no output, close the Ubuntu terminal down and restart it. It should now return nvm.

install-nvm-2.PNG