Differences from Other languages
Unlike the modern world multithreading server languages such as Java or C, Node.js is a single-threaded architecture. However, Node.js is highly scalable by running different Node.js processes using a load balancer.
Basically, Node.js is consisted of three things:
2. The event loop library and
3. A thread pool that handles all file input/output operations
Installing (Mac OS X)
- Download the Node.js Mac OS X installer from its official website https://nodejs.org. The latest stable version is v5.9.1 in the time of writing this post.
Open the installer from downloaded .pkg file and Click Continue and Agree when prompted some messages as usual as other app installers.
Type your admin-level password when prompted. If not, please ignore this step.
When Node.js is finished installing, you will see this screen that showing where Node.js and npm are installed.
You will also see a reminder to make sure that /usr/local/bin is in your $PATH. You can check your $PATH by typing
echo $PATHin your Terminal. If /usr/local/bin is included, you are fine and ready to use your
npmcommands in your Terminal in any working directory. If not, don't worry, you can see at Troubleshooting section in this post below how to fix.
- To test whether Node.js is installed on your machine, type
node -vin your Terminal. It will show the version of the Node.js that your installed.
What is Node.js & npm
Great, you have installed the most popular framework in your machine. But what is npm doing while I am installing Node.js?
Node.js is a command-line tool. After installing it, the node commands will be available on Terminal. These commands comes with two executables in mainly -
In Node.js world, the building blocks that contained groups of programming or business logic, are considered as modules or packages. This is where
npm comes in order to download and upload or manage these Node.js packages. The official site for
npm acts as a central registry and you can see there are a lot of useful packages written by other developer. You can also create and register one via
npm command as well to there.
Including the /usr/local/bin in your $PATH
- Open Terminal.
cd ~and this will bring you to home directory.
sudo vi .bash-login.
- Type your admin-level password.
Then you will see a [New File] or an existing one named
.bash_loginwill be look like as below.
ito bring insert task.
- If the
.bash_loginfile is new,
- If the file already has previous path variables,
- Just append
:/usr/local/bin:at the end of the existing PATH statement.
- Just append
Escapeto quit editing or inserting.
:wq[write and quit] and press
exitin Terminal and quit.
- Open the Terminal again and type
echo $PATHto verify your path.