diff --git a/01 Intro to NodeJS.md b/01 Intro to NodeJS.md index cdd40fd..d7ebf13 100644 --- a/01 Intro to NodeJS.md +++ b/01 Intro to NodeJS.md @@ -31,12 +31,38 @@ It is assumed that you can already program in a modern language such as Python o Make sure you have cloned the repository containing the sample code by following the instructions in the previous chapter. +## 1 Installing Node + +The simplest way to install the latest version of Node is to use the [Node Version Manager](https://github.com/creationix/nvm) tool. This can be installed using `cURL` as shown below. +``` +curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash +``` +Now you need to close the terminal and relaunch it. Try displaying the version of nvm. +``` +nvm --version +``` +If the nvm command is not found, make sure your `~/.profile` file contains the following line (add it if needed) then restart terminal and try again. +``` +[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh # This loads NVM +``` +Once this has been installed we can use it to list all the versions of node available and then installing the latest version: +``` +$ nvm list-remote + ... + v8.5.0 + v8.6.0 + v8.7.0 +$ nvm install 8.7.0 +$ node -v + v8.7.0 +``` + ## 1 Node Packages NodeJS can be extended through the use of **packages** and these are installed using the **Node Package Manager**. This was installed when we installed Node. ``` $ npm -v - 5.0.0 + 5.4.2 ``` One of the most valuable features of NodeJS is its package manager which allows you to install additional functionality in the form of _packages_. There are thousands of these to choose from and, in a later chapter, you will be shown how you can publish your own packages.