Getting Started with JavaScript in Windows 10
It’s easier than you might think!
Let’s face it: Sometimes, writing code on a Windows PC is no picnic.
Unlike in Mac OS X or with a Linux distribution, you don’t have easy access to a Bash terminal. Installing what you need can sometimes be a nightmare.
Good news, though — getting everything installed so you can start coding in JavaScript is actually very doable! You really only need three things: a code editor, a bash terminal, and node.
Let’s start with a code editor. If you already have your preferred code editor installed, great; if not, let’s go with Visual Studio Code (a popular choice and my personal preference). The default settings in the installer are fine.
Now for the terminal. There are a few different options you can use for this; we’ll use Git for Windows. Click download, then open the file to get started with the install. When it asks you to choose the default editor, choose Visual Studio Code (or your preferred editor if you’re using that instead). It should be fine to stick with the default for the rest of the installer prompts.
Next, download and run the Windows Installer for Node.js — this is what will allow you to run JavaScript code on your computer itself. All the default options should be fine here.
And we’re done! Open Git Bash (aka Git for Windows) and type node
, then hit Enter. This opens a console that acts as a sort of JavaScript sandbox.
Try typing console.log(“Hello world!”)
and then hit Enter again. That’s your first JavaScript program written on Windows!
To write actual full-fledged programs, you’ll probably want to use Visual Studio Code (or your preferred editor). To run those programs, just use Git Bash navigate to the directory where they’re stored (you can find many tutorials for this online if you’re unfamiliar with how to use a Bash terminal). Then type node [filename]
to run the program — for example, if the file is called index.js, type node index.js
and hit Enter.
Now you can code with JavaScript on Windows!