Setup Node.js development environment on Windows
Our mission in this post is to setup your computer for development so that you can start coding right away. These are a few things we will install on your computer:
Node.js itselfGitA modern code editorMongoDB (Optional)
So, let’s jump right in and get started with it.
Node.js
A little bit about Node.js, it is a beautifully written cross-platform open source JavaScript runtime environment built on the Google’s Chrome’s V8 JavaScript engine. Node.js basically lets you code application in JavaScript and run them on the backend on a server. When I said ‘cross-platform’, I really mean it. You can install Node.js on Windows and even deploy applications. Download Node.js from the official website. Since you are just starting to learn, it is recommended to download the LTS (Long Term Support) variant. The current latest LTS version available at the time of writing this post is 6.11.0. Once you’ve downloaded, run the installer, and you need not make any changes and just hit ‘Next’ on all the steps. Node.js setup comes built in with the Node Package Manager which is required to download and install third party modules. You will find yourself using NPM very often. So, do not change this setting while installing Node.js on your computer. Also, the setup automatically modifies the PATH variables so that you can run npm commands from the CMD. So, if you want to modify any of these settings go for Custom Setup; else I would recommend Express installation.
Once installed, search for ‘Node.js command prompt’ in the start menu and hit enter to run the console. This CMD window is everything to you for your Node.js career. This window has been initialized for using Node.js and NPM so that you can run your commands from this window. To verify, just run ‘npm –v’ to see the version of NPM installed on your computer. If you are following a Node.js tutorial elsewhere, you can run all the commands mentioned in that tutorial from this window here.
Git
Git is the most widely used and industry-specific version control system. You will learn about version control systems soon if you don’t know them already. Download Git for Windows here. Git will help you a lot in managing code for larger projects. Git is very easy to learn and get started. A short challenge-based guide is available online that can get you started with Git. Once you’ve run the installer, you may face a few steps where you will not be aware of your actions. There is this one step I would like to discuss. The step which says ‘Adjusting your PATH variable’ is one important step. Here you need to select how will you like to use Git on your computer. I always go for the second option ‘Use Git from Command Prompt’. Selecting this option will make the Git commands available in Node.js command prompt as well as in Git Bash. Git Bash is another command line tool included with Git; you can use it for development purpose or continue using the command prompt. Do not worry about rest of the steps, just keep hitting ‘Next’ on the installer. Explaining these steps is beyond the scope of this post, but you can search for Git installation on the Internet.
Once the installation is complete, you can open a command prompt window and type in ‘git –version’ to verify that you have Git installed.
Code Editor
Choosing a code editor can be a challenging task when you have so many options out there. You can choose something between a full-fledged IDE like WebStorm or a code editor like Brackets. Here are few recommendations:
WebStrom: The most powerful JavaScript IDE used by professionals. It is a paid tool, and I would recommend you to get started with a free one and later make an investment as you advance your career.Visual Studio Code: If you are already familiar with Visual Studio go for it. VS Code is a free open-source code editor brought to you by Microsoft. The program comes with a built-in debugger and syntax highlighting for various languages. Not just Node.js, you can code in a lot of other languages.Brackets: It is a powerful open source code editor available for all the platforms. It supports syntax highlighting in a ton of languages. And it comes with this great extension manager that lets you add more functionality and features to the tool. I personally use this tool, and I like features such as automatic web page refresh, extensions, and the keyboard shortcuts. Also, it adds an option to your right-click menu so that you can directly open project folders in Brackets.
These were just my recommendations; you are free to choose any IDE or editor. You can even write code in a simple Notepad if you are brave enough.
MongoDB
This is an optional step. MongoDB is a cross-platform document based database program. It is used in place of SQL in traditional Node.js CRUD applications. You can use SQL if you want but since MongoDB is widely accepted with Node.js, we’ve covered it here. You need to download MongoDB Community Server from here. Optionally you can install MongoDB Compass, a GUI tool to browse through your database. Once downloaded and installed, go to the MongoDB installation directly and navigate to the bin folder. The address may look something like this: Now run ‘mongod.exe’ to start your MongoDB server. And run ‘mongo.exe’ to interact with the server through the command line or use Compass if you prefer GUI. You can even add this directory to PATH variable to directly run mongod and mongo from the command line. You can learn here about changing your System Environment Variables Path. That’s it! You are ready to code your first Node.js application. You have the right tools and environment setup for development.