Khandaker Toihidul Islam
Software Engineer
Backend : PHP | Mysql | Symfony | CakePhp | Wordpress | Drupal
Frontend : Node js | Vue js | React Js | Javascript | HTML | CSS | Bootstrap
Tools , Server : Nginx | Apache | Git | Jenkins | Jira | Asana | Silenium | Spira

React in Digital Ocean server

To get a more recent version of Node.js you can add the PPA (personal package archive) maintained by NodeSource. This will have more up-to-date versions of Node.js than the official Ubuntu repositories, and will allow you to choose between Node.js v10.x (the Maintenance LTS version, supported until April of 2021), Node.js v12.x (the Active LTS version, supported until April 2022), and Node.js v14.x (the current release, supported until April 2023).

First, install the PPA in order to get access to its contents. From your home directory, use curl to retrieve the installation script for your preferred version, making sure to replace 10.x with your preferred version string (if different):

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

You can inspect the contents of this script with nano (or your preferred text editor):

  • nano nodesource_setup.sh

Run the script under sudo:

  • sudo bash nodesource_setup.sh

The PPA will be added to your configuration and your local package cache will be updated automatically. After running the setup script from Nodesource, you can install the Node.js package in the same way you did above:

  • sudo apt install nodejs

To check which version of Node.js you have installed after these initial steps, type:

  • nodejs -v
Output
v10.22.0

The nodejs package contains the nodejs binary as well as npm, so you don’t need to install npm separately.

npm uses a configuration file in your home directory to keep track of updates. It will be created the first time you run npm. Execute this command to verify that npm is installed and to create the configuration file:

  • npm -v
Output
6.14.6

In order for some npm packages to work (those that require compiling code from source, for example), you will need to install the build-essential package:

  • sudo apt install build-essential

You now have the necessary tools to work with npm packages that require compiling code from source.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *