Node.js is an open source server environment, utilizing asyncronous programming. What does "asyncronous programming mean"?
A typical syncronous task for a web server can be to open a file on the server and return the content to the client.
How a server side code handles a file request:
- Client browser sends the task to the servers file system.
- Clients browser waits while the file system opens and reads the file.
- The server returns the content to the client.
- The server waits to handle the next request.
Here is how asyncronous file request works:
- Client browser sends the task to the computer's file system.
- Server waits to handle the next request.
- When the file system has opened and read the file, the server returns the content to the clients browser.
- Node.js eliminates the waiting, and simply continues with the next request.
Node.js runs single-threaded, non-blocking, asynchronously programming, which is very memory efficient.
What Can Node.js Do?
- Node.js can generate dynamic page content
- Node.js can create, open, read, write, delete, and close files on the server.
- Node.js can collect form data.
- Node.js can add, delete, modify data in your database.
What is a Node.js File?
- Node.js files contain tasks that will be executed on certain events.
- A typical event is someone trying to access a port on the server.
- Node.js files must be initiated on the server before having any effect.
- Node.js files have extension ".js".
Homebrew is an open-source software package management system that simplifies the installation of software on Apple's operating system OSX and Linux.
Homebrew and Node.JS are not installed on OSX by default. Therefore you will need to verify and or install both on to your system for them to work.
Verify if Homebrew and Node.js are installed.
brew -v node -v
If neither return a version number you will need to install them. You should also have Command Line Tools for Xcode installed. If you do not, the installer for Homebrew will install them for you. This will take extra time.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install node
After installation you will be shown some information that you should pay attention too if you plan on using icu4c in any C or Java applications.
==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d ==> Summary 🍺 /usr/local/Cellar/node/15.13.0: 3,273 files, 55.6MB ==> Caveats ==> icu4c icu4c is keg-only, which means it was not symlinked into /usr/local, because macOS provides libicucore.dylib (but nothing else).
If you need to have icu4c first in your PATH, run: echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.profile echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.profile
For compilers to find icu4c you may need to set: export LDFLAGS="-L/usr/local/opt/icu4c/lib" export CPPFLAGS="-I/usr/local/opt/icu4c/include"
Updating, changing versions of Node.js.
If you are required ot use an alternate version of Node.js for a project you can switch between versions quite easily with Homebrew.
You should run
prior to these commands to ensure that any new versioned formulae are available.
brew install node@version
Where version is 0.10, 0.12, 10, etc. For example, to install Node.js v10.01.
brew install firstname.lastname@example.org
If you have another version of the node formula installed, you'll also need to run,
brew unlink node