How to Setup Node for the First Time
This article will save you a lot of hassle when trying to set up your local environment to build your first node application while also give you the flexibility to upgrade in the future.
There are only 2 steps.
- Install NVM
Download the latest nvm-setup.zip and install from https://github.com/coreybutler/nvm-windows/releases.
NVM is an abbreviation of Node Version Manager, this is will give you flexibility in the future when you want to change the Node version depend on the project, because sometimes you maintain an old project which requires an old version of Node.
If installed successfully then you can check the version by typing nvm --version
in the command prompt.
2. Install Node
Install Node by typing nvm install <version> [architecture]
in the command prompt. You can get the list of NPM<version>
on the NPM official website https://nodejs.org/en/download/releases. In this example, I will try to install Node version 10.24.0 in the default local PC architecture which is x64. Type nvm install 10.24.0
in the command prompt.
After installed you can use the Node by typing nvm use 10.24.0
in the command line.
You also can install the other version of Node, just use the same scriptnvm install <version>
and use it using nvm use <version>
. If you want to see the installed version of Node inside your machine just typing nvm list
in the command prompt.
Note: NVM is self-contained, so every global library you installed only exists within the version you are active on while installing it. For example, you install the Nodemon package (library for auto-reload) globally using npm install -g nodemon
while you are using Node version 10.24.0, then you can’t use Nodemon while you are active using Node 14.16.0.
Conclusion
Installing Node in the local machine is quite simple. Every time you start or import a Node project don't forget to check the version because some project might be working properly in the specific version, just use nvm use <version>
to change to the specific version.