← back to the blog

Building a Node Express Backend: Replacing Ruby on Rails Existing Source

Posted on January 5th, 2018 in Javascript by Elijah

Lets start by creating a directory. This can be done in many ways(from terminal, using Mac Finder App, IDE), but I like to start by using the terminal, or more specifically, iTerm. Lets navigate to the directory we want the new application to be.  I have a folder called 'js-projects/' for all of the node projects I have worked on.  So thats where I navigate to. Then run the command:

$ mkdir mynodeapp

I'm working from a Macbook Pro & use Homebrew as a package manager.  We want to use the most current stable versions of all software when we're developing.  Software moves so fast. Its nice to start with the latest stable version because it will quickly be out of date anyway. 


I also use yarn instead of just npm.  Having yarn already installed, I run:

$ yarn --version


This sounds old. Checking the most current stable version of yarn at time of writing this blog shows that its version 1.3.2.  Using yarn docs https://yarnpkg.com/en/docs I found how to update.  The first option was to do upgrade with homebrew.  Its been quite a while since I've installed yarn, I've just been arrogantly using it in the background just taking for granted that it was just taking care of itself.  My assumption is also that if it suggests upgrading through homebrew, I also must have been suggested to install through homebrew.  Of course I don't remember on this machine how I installed yarn over a year ago. Check the list of homebrew packages with: 


$ homebrew list
... //all the brew packages I have


Being mostly certain this had to be the correct install, I upgraded yarn to its most current stable with the command:

$ brew upgrade yarn


After installation, I always try to open a new terminal window. 

$ yarn --version


Now yarn is up to date.  I also wanted to work on most current stable version of node which is v9.2.0 as of today.  I look at my nvm list, because I have projects which require different node versions. 

$ nvm list
->       v7.2.1
default -> 7.2.1 (-> v7.2.1)
node -> stable (-> v9.2.0) (default)
stable -> 9.2 (-> v9.2.0) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> N/A)
lts/argon -> v4.8.6 (-> N/A)
lts/boron -> v6.12.0 (-> N/A)
lts/carbon -> v8.9.1 (-> N/A)

Lets go ahead and switch to the stable version of node.

$ nvm use stable

Then we make a .nvmrc file to make sure you're running the correct version of node.js.  

$ touch .nvmrc

Then we open this file in a text editor, ide, or terminal.  I currently use an IDE. It doesn't matter how you do it, just edit the contents of the file to:

 1   v9.2.0   

We can start simply and run 

$ nvm use 

every time you open a new terminal.  I have a more important project that I want to keep at default nvm so I'll just keep it simple for now.  More tomorrow.