Install Node.Js, npm on Windows and Ubuntu systems

By CodersDrive
21-Jul-2020
Laravel

In this post you will see the step by step procedure to install 'npm' on your Windows or Ubuntu system. For Laravel application 'npm' is required to download the 'js' packages required for your application and also for 'Scaffolding' of your application.

Install npm on Windows

On windows system installation of Node.js will also install npm. First go to the page https://nodejs.org/en/download/ and download the required 32-bit or 64-bit Windows installer(.msi) file and install it.

Install npm on windows 10 Steps for install
  • When installation is started you will be prompted to Node.js installation wizard, click Next
  • Accept the license agreement and click Next
  • Now it will ask for the installation location, prcoeed with deafult location or select your preferred location and click Next
  • Install with default options in the coming steps and click Next on all screens
  • Finally click the Install button. After installation is done click Finish

Thats all Node.js and npm are installed on your Windows system. You can check the versions installed using the commands below.

To check Node.js version, enter below at your windows CMD or Powershell.

node -v

To check npm version, enter below at your windows CMD or Powershell.

npm -v
Install npm on Ubuntu 20.04
Install Node.js with Apt from default repositories

Ubuntu 20.04 contains a stable version of Node.js in its default repositories itself. Though newer versions of Node.js may be avaialable on Node.js repositories, the one installed from Ubuntu repositories will be stable with current version of Ubuntu.

To install Node.js from default repositories use the following commands at your terminal.

sudo apt update
sudo apt install nodejs

First command will refresh your local package index and the second command will install Node.js. You can check the installation by verifying the installed Node.js version using the following command

node -v

Now we proceed to install npm using the following command at your terminal.

sudo apt install npm

Once the installation is successful, you can verify it by checking the version installed using the following command.

npm -v

Find below the screenshot you will see with node and npm versions installed on your Ubuntu system.

Install npm on ubuntu 20.04 Installing Node.js with Apt Using a NodeSource PPA

If you have specific version requirement of Node.js for your project whcih is not avaialable in default repsotories, you can download your required verison from NodeSource PPA.

First you will install the NodeSource PPA in order to access its packages using the following commands.

cd ~
curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh

First line will change directory to your home. Next command will download nodesource_setup.sh script file using curl of verison 14.x (replace it with your required version) to your home directory.

nano nodesource_setup.sh

You can verify whether the downloaded script file is safe to run by editing the file use above command. If you are satisified with it next proceed to next command as below.

sudo bash nodesource_setup.sh

The above command will add NodeSource PPA to your system repositories.

Now you can install node.js and npm from added repositories using the below commnads.

sudo apt install nodejs
sudo apt install npm

Once installed successfully, check the installed version using below commands.

node -v
npm -v

Hope you successfully installed Node.js and npm on your Ubuntu system.


Laravel Node.js npm Ubuntu Windows

Search blog..!

Connect with us