Setup for the Exercises: Node.js, Git and VS Code
Install VS Code, the LTS version of Node.js and Git on Windows or macOS, check them with --version, make a free GitHub account, tell Git your name and email, and make the mongodb-course folder every exercise goes in.
Novice · MongoDB · Git · Updated
After this lesson you can
- Say what Node.js, Git and VS Code each do for this course's exercises, and why a database course needs Node.js
- Check that Node.js, npm and Git are installed with --version, and set Git's name, email and default branch with git config --global
Key takeaways
- The exercises' tests are small programs that run with Node.js, so a database course needs Node even though you write queries, not programs. Module 5 uses Node for real.
- Git copies each exercise from GitHub to your computer and sends your finished work to a repository of your own. VS Code is where you edit and run it.
- Install the LTS version of Node.js. Node 26 is the LTS version, and every exercise runs on Node 24 or later.
- node --version, npm --version and git --version print the versions you have. "Not recognized" means the terminal can't find the program yet.
- git config --global sets the name and email Git writes on your work, once per computer.
You'll write your queries in mongosh, but each exercise also comes with tests that check them for you, and those tests are small programs. Getting an exercise, checking it and handing it in takes three more tools, the same ones professional developers use every day. You set them up once, now, in about half an hour.
Why a database course needs these tools
| Tool | What it does in this course | Cost |
|---|---|---|
| VS Code | A code editor: a text editor made for code. You open each exercise in it and write your queries in its queries.js file. |
Free |
| VS Code's terminal | A terminal: a window where you type a command and read the answer. VS Code has one built in, PowerShell on Windows and zsh on a Mac. | Comes with VS Code |
| Node.js and npm | Node.js runs JavaScript programs on your computer, such as an exercise's tests. npm, which comes with it, installs the packages the tests use and runs them with npm test. Module 5 uses Node for a real web API. |
Free |
| Git and GitHub | Git copies each exercise from GitHub, a website that keeps code online, and later sends your finished work to a repository of your own there. That's how you hand an exercise in. | Free |
You don't need to know any JavaScript for Modules 1 to 4: the tests are handed to you, and your part is the queries.
Install them
| Windows | macOS | |
|---|---|---|
| How | In the Terminal app, type each command and press Enter. Click Yes if Windows asks. | In the Terminal app, with Homebrew, as in Setup: MongoDB, mongosh and Compass |
| VS Code | winget install -e --id Microsoft.VisualStudioCode |
brew install --cask visual-studio-code |
| Node.js | winget install -e --id OpenJS.NodeJS.LTS |
brew install node |
| Git | winget install -e --id Git.Git |
brew install git, then brew install --cask git-credential-manager |
The download pages work too: code.visualstudio.com, nodejs.org (choose the version marked LTS) and git-scm.com, each with its suggested settings. LTS means long-term support: the version that gets fixes for the longest. Node.js 26 is the LTS version now, and every exercise runs on Node 24 or later.
Git Credential Manager comes with Git on Windows. It signs you in to GitHub through your browser the first time you send work there, so you never type a password into the terminal.
Check the versions, and make the course folder
Close VS Code if it's open, then open it again, so its terminal can find the new programs. Open the terminal with Terminal > New Terminal, then type each command and press Enter:
node --version
npm --version
--version is read "dash dash version": it asks a program which version it is. With Node.js 26.13.1, the version the course was checked with, you'll see this; a newer number, or one starting with 24, works as well:
v26.13.1
11.20.0
The first line is Node's version, the second npm's. Then check Git with git --version: it answers git version 2. and more numbers (the course was checked with 2.56). Any recent version works.
Every exercise in this course goes in one folder, mongodb-course, in your home folder. Make it in VS Code's terminal:
mkdir ~/mongodb-course
~ (read "tilde") is your home folder, and mkdir means "make directory", another word for a folder. Choose File > Open Folder, open mongodb-course, and if VS Code asks whether you trust the authors of the files, choose Yes: they're your own.
A GitHub account, and your name for Git
Make a free account at github.com/signup, or sign in if you have one. Your username is part of every repository's address, such as github.com/your-name/exercise-mongodb-your-first-recipes, so pick one you'd be happy to show someone you'd like to work for.
Git writes a name and an email on every piece of work you save. Use your own name and the same email as your GitHub account, so GitHub links your work to you:
git config --global user.name "Sam Lee"
git config --global user.email "sam.lee@example.com"
git config --global init.defaultBranch main
--global means for every project on this computer, so you do it once. The third line names a new repository's first line of work main, the name GitHub uses. None of the three prints anything. Check them:
git config --global --list
user.name=Sam Lee
user.email=sam.lee@example.com
init.defaultbranch=main
To fix a typo, run the same line again with the right value: it replaces the old one.
If something goes wrong
| What you see | What to do |
|---|---|
The term 'node' is not recognized (Windows) or zsh: command not found: node (Mac), or the same for git |
VS Code was open while it installed, or it isn't installed yet. Close VS Code completely, open it again, and retry. |
node --version prints a number starting v22 or lower |
That Node.js is older than the exercises need. Install the LTS version, then reopen VS Code. |
git config --global --list shows a typo |
Run that git config --global line again, spelled right. |
Check yourself
2 questions to try on the lesson page.
So what
With an editor, Node.js, Git and a GitHub account, you have everything an exercise needs: a way to get it, a way to check it, and a way to show it to anyone.