Note: This series is based on React 16 — if you are using a newer version, your mileage may vary.
I was tasked without setting up a new codebase for a frontend rewrite at work this week. I’ve used Create React App for all my previous React projects, but I didn’t want to default to that — after all, stack decisions I make right now could affect the company for the next 3-5 years. I wanted to make sure I knew and understood all the pieces of this codebase since I’m responsible for it, so I decided to research different options and roll my own React environment.
How to Install NodeJS
Before you can set up a React project, you’ll need Node installed. While you aren’t necessarily creating a Node server here, Node is still used to add third party packages (via npm, which is bundled with Node) to your project as well as run scripts such as a local development server.
To install Node, you can take a couple of different routes.
Option 1: Install it from the NodeJS website. This will install a single version of Node on your machine as well as npm.
I chose to use Nodenv because it’s similar to rbenv, which I’ve used in the past. You can install Nodenv a couple of different ways, but I installed it via Homebrew because I’m on OS X and it’s dead simple.
After installing Nodenv, you can run
nodenv install -l to get a list of available versions to install. You can then run
nodenv install x.y.z (replacing
x.y.z with your desired version number) to install the Node version of your choice. I chose 8.11.3, the version recommended on the NodeJS website at the time of this writing.
Therefore, I ran:
nodenv install 8.11.3
You should now have Node installed. In the next post, you’ll initialize your project and install React.