Install Nodejs

Posted on  by admin

The first step in using Node.js is the installation of the Node.js libraries on the client system.

How to Install Node.js on Windows

Below are the steps to download and install Node.js in Windows:. Go to the site and download the necessary binary files.

How to Install NPM on Windows 10/8/7

In our example, we are going to Download Node.js on Windows with the 32-bit setup files. Step 2) Run the installation. Double click on the downloaded .msi file to start the installation.

Click the Run button on the first screen to begin the installation. Step 3) Continue with the installation steps. In the next screen, click the “Next” button to continue with the installation. In the next screen, Accept the license agreement and click on the Next button.

Step 5) Set up the path. In the next screen, choose the location where Node.js needs to be installed and then click on the Next button.

First, enter the file location for the installation of Node.js. This is where the files for Node.js will be stored after the installation. Click on the Next button to proceed ahead with the installation. Step 6) Select the default components to be installed. Accept the default components and click on the Next button.

Step 7) Start the installation.

You Might Like:

In the next screen, click the Install button to start installing Node.js on Windows. Step 8) Complete the installation. Click the Finish button to complete the installation. The other way to install Node.js on any client machine is to use a “package manager.”.

On Windows, the NPM (Node Package Manager) download is known as Chocolatey.

  • It was designed to be a decentralized framework for quickly installing applications and tools that you need.
  • For installing NPM on Windows via Chocolatey, the following steps need to be performed.
  • Step 1) Installing Chocolatey – The Chocolatey website ( has very clear instructions on how this framework needs to be installed.

Sample application

The first step is to run the below command in the command prompt windows. This command is taken from the Chocolatey web site and is the standard command for installing Node.js via Chocolatey.

The below command is a PowerShell command which calls the remote PowerShell script on the Chocolatey website.

This command needs to be run in a PowerShell command window. This PowerShell script does all the necessary work of downloading the required components and installing them accordingly.

@powershell -NoProfile -ExecutionPolicy Bypass -Command “iex ((new-object wet.webclient).DownloadString(‘’))” && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin. Step 2) The next step is to install Node.js to your local machine using the Chocolatey, package manager.

Test the application

This can be done by running the below command in the command prompt. cinst nodejs install. If the installation is successful, you will get the message of the successful installation of Node.js.

Note: If you get an error like “C:\ProgramData\chocolatey\lib\libreoffice\tools\chocolateyInstall.ps1” Then manually create the folder in the path. The basic functionality of the “require” function is that it reads a JavaScript file, executes the file, and then proceeds to return an object.

Using this object, one can then use the various functionalities available in the module called by the require function.

So in our case, since we want to use the functionality of HTTP and we are using the require(http) command.

In this 2nd line of code, we are creating a server application which is based on a simple function.

This function is called, whenever a request is made to our server application.

Create a Dockerfile for Node.js

When a request is received, we are asking our function to return a “Hello World” response to the client. The writeHead function is used to send header data to the client, and while the end function will close the connection to the client.

We are then using the server.listen function to make our server application listen to client requests on port no 8080. You can specify any available port over here.

Save the file on your computer: C:\Users\Your Name\ firstprogram.js.

In the command prompt, navigate to the folder where the file is stored. Enter the command Node firstprogram.js. Now, your computer works as a server! If anyone tries to access your computer on port 8080, they will get a “Hello World!” message in return!

Start your internet browser, and type in the address: http://localhost:8080. We have seen the installation of Node.js via the MSI installation module, which is available on the Node.js website. This installation installs the necessary modules which are required to run a Node.js application on the client. Node.js can also be installed via a package manager. The package manager for windows is known as Chocolatey. By running some simple commands in the command prompt, the Chocolatey package manager automatically downloads the necessary files and then installs them on the client machine.

A simple Node.js application consists of creating a server which listens on a particular port. When a request comes to the server, the server automatically sends a ‘Hello World’ response to the client.

Modified6 months ago. I have installed Ubuntu Bash on Windows. I already have nodejs and npm on my windows machine at C:\Program Files\nodejs. In the bash shell in Windows, I am running a script which uses npm install command. The script is giving following error. 1212 gold badges6060 silver badges147147 bronze badges. 147147 bronze badges. Note: Before following the steps below, first try to restart your shell.

You can install Node.js and NPM with your Windows PowerShell as well, so if you've done that it won't work properly for your Subsystem. That means you have to install it twice (Powershell and Subsystem) or decide on one thing.

If the preceding text, has not helped you, this is how to solve the problem:Remove your current installations.

Install node the right way.This is for version 14 (view current LTS version):. Then install build tools so you can install add-ons for npm later. Now you can type in. to check whether Node.js and NPM are installed correctly. If it shows nothing, restart the shell.If it still shows the same error, restart the WSL/ PC or try with sudo npm -v. Here are two links that may also help you.

class MyImage extends NodeBaseImage {}

Also, take a look at the Node Version Manager (NVM). With it, you can easily switch back and forth between versions. 11 gold badge88 silver badges1616 bronze badges.

1616 bronze badges. The solution provided by phucanhapril on May 24, 2017 in this thread worked for me. To summarise, edit ~/.profile and change your PATH to this:.

(By default it does not include /usr/bin).

I am not quite sure why npm doesn't work properly in the first place, or why /usr/bin isn't in PATH by default, but the solution worked for me.

2929 gold badges121121 silver badges200200 bronze badges. 200200 bronze badges. I had the same problem to solve I installed "NVM" in my Subsystem. Follow these steps and see if it will solve for you:. Elton José de SouzaElton José de Souza.

You can try sudo npm install it was a solution in my particular case. this is enough, if you still face the problem . node installation needs restart, close you ubuntu window and start again it will solve your problem :). Nikhil SharmaNikhil Sharma.

Linux command for install nodejs and npm. Set path in linux. 3333 bronze badges. I had the same problem. This is what I did. Type node -v and npm -v commands in Windows PowerShell and check if node and npm are properly installed. Add this to the ~/.zshrc or ~/.bashrc file.

Type source ~/.zshrc and/or source ~/.bashrc. Type node -v and npm -v commands in bash or zsh shells and the correct versions should now appear. 4949 bronze badges. I had this issue in both Debian and Ubuntu (though in Ubuntu the nvm command did work) when I was running Windows 10 version 1703. Then when I upgraded to version 1903 the problem disappeared. 44 gold badges2828 silver badges5757 bronze badges. 5757 bronze badges. I had the same error and it may seem silly, but I fixed it by simply typing exit in the console and opening it again.

11 gold badge22 silver badges1212 bronze badges. 1212 bronze badges. On Visual Studio -> Tools -> Options -> Projects and Solutions -> Web Package Management -> make sure $(PATH) is above all the rest. As long it is not located at the top of the list VS will try to use VS tools instead of npm.

You should also refer windows to the current npm version by following this screenshot, after try npm --version. Changing npm path:. 4949 bronze badges. 48411 gold badge44 silver badges1212 bronze badges. 44 silver badges1212 bronze badges. I received this error when I modified my "~/.bashrc" file to shorten up the bash directory. At first I had:. ..But then could not run any node operation. I rolled it back and the error stopped happening.

After some troubleshooting, I was able to fix the error by adding ~ before the $ on PS1='${debian_chroot:+($debian_chroot)}\u\h:\W\~$. 3030 bronze badges. I just read through many threads trying to do this. There is complete documentation for setting up node, nvm, and npm in wsl, here:

If you already installed node and npm using the following commands,. NPM will not work. You must first uninstall them using:. Follow the guide to completely uninstalling here: How can I completely uninstall nodejs, npm and node in Ubuntu.

Then reinstall from the windows guide referenced above.The windows guide has many other useful resources.

Create a .dockerignore file

The Tldr to install(from Microsoft Docs):. 4949 bronze badges. If you are new to developing with Node.js and want to get up and running quickly so that you can learn, install Node.js on Windows. This recommendation also applies if you plan to use a Windows Server production environment. It is always recommended to remove any existing installations of Node.js or npm from your operating system before installing a version manager as the different types of installation can lead to strange and confusing conflicts.

Build image

For example, the version of Node that can be installed with Ubuntu's apt-get command is currently outdated. For help with removing previous installations, see How to remove nodejs from ubuntu.). Open your Ubuntu command line (or distribution of your choice). Install cURL (a tool used for downloading content from the internet in the command-line) with: sudo apt-get install curl.

Install nvm, with: curl -o- | bash. As of January 25, 2022, NVM v0.39.1 is the most recent version available. You can check the GitHub project page for the latest release of NVM, and adjust the above command to include the newest version.Installing the newer version of NVM using cURL will replace the older one, leaving the version of Node you've used NVM to install intact.

For example: curl -o- | bash.

View local images

To verify installation, enter: command -v nvm ..this should return 'nvm', if you receive 'command not found' or no response at all, close your current terminal, reopen it, and try again.

Learn more in the nvm github repo. List which versions of Node are currently installed (should be none at this point): nvm ls.

Install both the current and stable LTS versions of Node.js. In a later step, you'll learn how to switch between active versions of Node.js with an nvm command.

Tag images

Install the current stable LTS release of Node.js (recommended for production applications): nvm install --lts. Install the current release of Node.js (for testing latest Node.js features and improvements, but more likely to have issues): nvm install node.

List what versions of Node are installed: nvm ls you should see the two versions that you just installed listed. Verify that Node.js is installed and the currently default version with: node --version.

Then verify that you have npm as well, with: npm --version (You can also use which node or which npm to see the path used for the default versions).

To change the version of Node.js you would like to use for a project, create a new project directory mkdir NodeTest, and enter the directory cd NodeTest, then enter nvm use node to switch to the Current version, or nvm use --lts to switch to the LTS version.

You can also use the specific number for any additional versions you've installed, like nvm use v8.2.1.

(To list all of the versions of Node.js available, use the command: nvm ls-remote). n is a long-standing nvm alternative that accomplishes the same thing with slightly different commands and is installed via npm rather than a bash script.

fnm is a newer version manager, claiming to be much faster than nvm. (It also uses Azure Pipelines.).

Volta is a new version manager from the LinkedIn team that claims improved speed and cross-platform support. asdf-vm is a single CLI for multiple languages, like ike gvm, nvm, rbenv & pyenv (and more) all in one.

nvs (Node Version Switcher) is a cross-platform nvm alternative with the ability to integrate with VS Code. This “remote” scenario is a bit different than you may be accustomed to.

Next steps

WSL supports an actual Linux distribution where your project code is running, separately from your Windows operating system, but still on your local machine. The Remote-WSL extension connects with your Linux subsystem as if it were a remote server, though it’s not running in the cloud… it’s still running on your local machine in the WSL environment that you enabled to run alongside Windows.


Linux-based Intellisense and linting is supported. Your project will automatically build in Linux. You can use all your extensions running on Linux (ES Lint, NPM Intellisense, ES6 snippets, etc.).

containers, images, node.js, node, dockerfiles, node, coding, build, push, run