Node.js is an open-source, cross-platform JavaScript runtime environment that executes JavaScript code outside of a web browser. It was developed by Ryan Dahl in 2009 and has since become one of the most popular and widely-used JavaScript platforms for server-side development.
Node.js is built on Chrome`s V8 JavaScript engine and allows developers to write server-side applications in JavaScript. It uses an event-driven, non-blocking I/O model, which makes it a good choice for building scalable, real-time applications. With Node.js, developers can build applications that handle multiple simultaneous connections, such as chat applications, real-time data streaming, and online games.
Node.js provides a rich library of modules, which are pre-written code snippets that can be used to perform specific tasks. This makes it easy for developers to build and scale applications quickly, as they can use existing modules instead of writing code from scratch. The Node.js community is also very active and constantly adding new modules to the library, which makes it easier to add new features to your application.
Node.js has been widely adopted by companies and organizations of all sizes, including PayPal, Walmart, Netflix, and NASA. It is also used for a variety of applications, such as building web servers, creating REST APIs, and building command-line tools. With its versatility, scalability, and growing community, Node.js is an excellent choice for building modern applications.
Step by Step to install NodeJS on Ubuntu 18.04
Option 1
To install Node.js on Ubuntu 18.04, follow these steps:
- Update the package index:
sudo apt-get update
- Install the necessary packages to add a new repository:
sudo apt-get install curl software-properties-common
<
li>Add the Node.js PPA (Personal Package Archive) to your system:
- Update the package index again:
sudo apt-get update
- Install Node.js:
sudo apt-get install nodejs
- Verify the installation by checking the version of Node.js:
node -v
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
Note: The above steps will install the latest version of Node.js (14.x) available in the Node.js PPA. You can also choose to install a different version of Node.js by specifying the version number in step 3.
Options 2
Yes, there is another way to install Node.js on Ubuntu 18.04. You can install it using the NVM (Node Version Manager), which allows you to manage multiple Node.js versions on a single system. With NVM, you can easily switch between different versions of Node.js as needed.
Here are the steps to install NVM on Ubuntu 18.04:
- Download the NVM installation script using curl:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
- Verify that NVM has been installed:
command -v nvm
- Load NVM into your shell session:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
- Check the available Node.js versions:
nvm ls-remote
- Install the desired version of Node.js:
nvm install 14.15.4
- Use the installed version of Node.js:
nvm use 14.15.4
With NVM, you can easily switch between different versions of Node.js, install new versions, and manage your Node.js environment.