Keep referring to this article by Mytour to learn how to install Node.js on Windows, Linux, and Mac OS.
Node.js Installation Guide
Setting up the local environment
To set up the environment for Node.js, you'll need the assistance of two software programs installed on your computer: a text editor and the Node.js binary installation.
Text Editor
A text editor is used to input your program. Some useful text editors include Notepad++ (on Windows), OS Edit command, Brief, Epsilon, EMACS, Vim, or vi.
On different operating systems, the names and versions of text editors may vary. For example, Notepad is used on Windows, while vim or vi can be used on both Windows and Linux or UNIX.
Files created with text editors are called source files and contain the source code of the program. Source files for Node.js programs typically have the file extension '.js'.
Before starting programming, ensure you have a text editor available and enough experience to write a computer program, save it to a file, and execute it.
Node.js Runtime
Code written in the file is simply JavaScript. The Node.js compiler is used to interpret and execute your JavaScript code.
Node.js distribution appears as binary installations for SunOS, Linux, Mac OS X, and Windows, with versions available for both 32-bit (386) and 64-bit (amd64) x86 architectures.
In the following section, Mytour will guide you on how to install Node.js binaries on various operating systems.
Download the latest version of Node.js
To download the latest version of Node.js and install it, you can visit the Node.js download page. Below is a table listing the available versions on different operating systems:
Installing Node.js on UNIX/Linux/Mac OS X, and SunOS
Based on the architecture of different operating systems, download and extract the compressed files node-v6.3.1-osname.tar.gz into /tmp, then move the extracted files to the directory /usr/local/nodejs. For example:
$ cd /tmp
$ wget http://nodejs.org/dist/latest/node-v14.7.0-linux-x64.tar.gz
$ tar -xvf node-v14.7.0-linux-x64.tar.gz
$ mkdir -p /usr/local/nodejs
$ mv node-v14.7.0-linux-x64/* /usr/local/nodejs
Add /usr/local/nodejs/bin to the PATH environment variable.
Install Node.js on Windows
Use the MSI file and follow the instructions to install Node.js. By default, the installer uses the Node.js distribution in C:\Program Files\nodejs. However, it's recommended to store the installer in the C:\Program Files\nodejs\bin directory on the Windows PATH environment variable. Close and reopen Command Prompt to apply the changes.
Verify Installation: Execute the file
Create a file named js and name it main.js (on Windows or Linux), then input the following code:
/* Hello, World! program in node.js */
console.log('Hello, World!')
The next step is to execute the main.js file using the Node.js interpreter to see the result:
$ node main.js
If everything works smoothly, the above code will return the result:
Hello, World!
In the above article, Mytour has just guided you on how to install Node.js. Additionally, readers can refer to some other articles available on Mytour to learn more about EventEmitter in Node.js.
