Discover how the files for a Node.js application debugging and performance optimization course are organized, then configure your workstation for Node.js development, including Visual Studio Code and Docker.
- [Instructor] Let's make sure that your development environment has everything that you need to follow along. First, you'll need Node.js version eight or higher, the current long-term support version. Next, you'll need Docker, a containerization program. We'll be using the free Community Edition from docker.com. Please install it now if you don't already have it. You'll need some sort of IDE or text editor. I'm gonna be demonstrating using Visual Studio Code editor, available from code.visualstudio.com.
Visual Studio Code is free, open source, and available on Windows, Mac, and Linux. The use of Visual Studio Code is not required, but you'll be able to follow along with the feature demonstrations if you have it. If you'd like to learn more, check out Learning Visual Studio Code in our library. You're gonna need some sort of terminal application. Any terminal will work, including Terminal.app for Mac, and PowerShell for Windows. The only requirement is that you must be able to execute Node.js from the terminal.
Visual Studio Code, the editor I'm going to be using to demonstrate, includes an integrated terminal, so I'll use it for cross-platform consistency. Finally, you're going to need a modern web browser. For this course, I'm gonna be demonstrating using Google Chrome, available from google.com/chrome. Chrome is not required for this course, but there is one video that demonstrates debugging techniques using Chrome. Beyond the software, if you have access to the exercise files for this course, you can download them to your desktop.
We'll start with a complete, but broken, rock-paper-scissors game written in Node.js. Throughout, we'll make incremental changes to debug and tune up the application. The exercise file structure reflects how the course progresses. Within it are folders named for each chapter and video. For example, we'll be setting up the application in chapter zero, video five, which will be in a folder named 00_05. If there are no code changes in a video, then there won't be a folder.
Within each folder, there are two subfolders, begin and end, which contain the respective begin and end states of the code base. To prepare, we'll copy the 00_05 begin folder and paste it on the desktop. Then, we'll rename the folder to rock-paper-scissors. This is where we'll work throughout the course. Let's switch to the desktop and do it now. From the desktop, navigate to the Exercise Files folder, then the 00_05 folder, and select begin.
Right-click and go to Copy. You can close the folder, then right-click on the desktop and go to Paste. Finally, right-click on the pasted folder and choose Rename, and rename it to rock-paper-scissors. Our exercise files are ready to begin. Let's open up Visual Studio Code. Let's learn how to open up the terminal by taking the long way.
Navigate up to the view menu, then move down and select Integrated Terminal. The terminal will open in the bottom of the window. As you can imagine, there's a faster way. Close the terminal by clicking the X in the upper right-hand corner of the terminal. On your keyboard, press Control and backtick to open up the terminal. That's a lot faster. You can press Control + backtick again to close the terminal as well.
Open the terminal again by pressing Control + backtick, and this time we're really going to use it. I'm going to verify that Node is installed, and then show the version number. Type the command: node, space, dash v, and press Return. I'm using 8.11.2, the long-term support version that was current during recording. Let's see if npm is available as well. Type the command: npm, space, dash v, and press Return.
I'm using 5.6.0, which is the version that was included with the LTS version of Node. When complete, press Control + backtick to close the terminal. We're gonna need some extensions to optimize the source code editor for Node.js development. We're gonna be using ESLint for coding standards, EditorConfig for VS Code for configuring editor defaults, Node.js Modules Intellisense for autocompletion of packages, and npm for package.json support.
Let's install them now. Back in Visual Studio Code, go to View, then go down to Extensions. First, search for eslint, which integrates the popular linting engine. I'm gonna be using ESLint 1.4.10. Click Install. Next, search for editorconfig, which will show EditorConfig for VS Code, which is at version 0.12.3.
Click Install. Then search for node.js, and select Node.js Modules Intellisense, which is at version 1.5.0. Click Install. Finally, we'll need to search for npm, which is at version 0.3.4. Click Install. Now that all the extensions have been installed, let's reload the editor by clicking Reload to activate them.
We've got everything we need for our editor. Now that it's ready, let's take a look at our demo application.
- Building a troubleshooting mindset
- Why measure performance?
- What's a microservice architecture?
- Managing microservices with PM2
- Effective logging strategies
- Debugging Node.js applications
- Benchmarking performance
- Profiling code execution
- Knowing what to optimize