What is Node.js?
JavaScript can be installed on the server i.e., it is an open source, cross-platform JavaScript runtime environment for developing server-side and networking applications. This popular server platform is built on Chrome’s V8 JavaScript engine and enables you to use JavaScript outside of a browser.
Why Node.js?
Apart from being one of the most popular programming languages on the planet, JS is powerful and easy to learn. And Node is, among other things, JS on the server.
Node.js uses a non-blocking I/O model and asynchronous programming style. While JS is a single-threaded language, this poses no significant issues for well-behaved Node applications. JS web developers are used to asynchronous programming in the browser through the use of callbacks.
Node also has a secret weapon in the battle for scalability: the event loop. Using asynchronous programming techniques, combined with the event loop, which processes I/O requests in separate threads in the background, Node can achieve ludicrous mode scalability.
Node.js community is engaged, active, and open. Code sharing is the norm in the Node community through the npm registry, where you can find lots of code to use in your applications, complete with documentation and source code.
Node.js learning path has a GitHub repo that contains every example from every tutorial, so you can run the examples yourself and follow along with the material.
What is non-blocking & asynchronous?
Node.js is a single-threaded and highly scalable system. Instead of separate processes and threads, it uses asynchronous, event-driven IO operations. This ensure that the language can achieve high output via single-threaded event loop and non-blocking IO. Further, by doing asynchronous processing on a single-thread under typical web loads, more performance and scalability can be achieved.
A non-blocking operation will not wait for IO operation to complete. A non-blocking call initiates the operation, leaves it for the operating system to complete returning and immediately without any results.
3 approaches to installing Node.js and npm
The best way to install Node.js and npm is through Node.js Version Manager, or nvm. With nvm, you can install multiple versions of both the Node.js runtime and npm, and they can all coexist i.e., you need not uninstall one version of Node.js or npm to insall another (just tell nvm which one you want to use). It’s great for compatibility testing and managing your Node.js environment in general.
The easiest approach is to download the package from your platform directly from the Node.js projects’ Node.js Downloads page and run the installation program. This approach is ideal for Windows users, but it also works for MacOS and Linux as well.
If you are a Mac user, a better approach is to use Homebrew. Homebrew bills itself as the ‘missing package manager for MacOS.’
Choosing between long-term support (LTS) or current release!
The Node.js release team designates even-numbered major releases as LTS releases. The LTS releases are supported for up to 3 years from the date of their original release, during which time the releases go from current (in the last 6 months) to active LTS (18 months, minor revisions only) to maintenance LTS (12 months, patch releases only). This means that you can be sure that a LTS release is stable for a considerable period of time.
Install Node.js on MacOS only
To install the current version of Node.js and npm via Homebrew, open a terminal window on your Mac and enter the following command.
%brew install node
Or to install the particular version, enter the following command
%brew install node@16
To check the node version
%node -v
v14.18.0
Installing VS code
To follow along with all the tutorials, you will need an editor. For this, VS code will be installed.
To install VS code, go to the Visual Studio Code page and the matching version should auto-detected. For MacOS, once the ZIP file has been downloaded, copy the APP file to the applications folder.
Now you can run all tutorials through VS code. Have fun!!!
Will review your comment and get back!