Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Debugging Node Applications with Google Chrome!
You have completed Debugging Node Applications with Google Chrome!
Preview
Debugging is more than just logging out values. You'll discover more about what debugging is in this video.
To use git to download the project to your local machine, paste this to your terminal:
git clone https://github.com/treehouse-projects/reverse-app-node.git
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
Hello world, Andrew here, JavaScript
developer and teacher here at Treehouse.
0:04
In this workshop,
I'll show you the professional tools and
0:08
techniques to debug your
node.js applications.
0:11
The process of debugging can be described
as identifying errors in your code and
0:14
removing them.
0:18
What comes to mind when I say debugging?
0:19
Maybe writing a console.log statement.
0:21
[SOUND] Let's discuss some of the cons
of using console.log as a way to check
0:24
the state of your application.
0:29
When building a web application, all
HTTP requests get logged to the console.
0:31
Attempting to log out your variables
alongside the noise of the HTTP requests,
0:36
may make debugging challenging when trying
to find the value you're debugging.
0:41
And what if the value logged out
is exactly what you're expecting?
0:45
You have to stop your application,
write another console.log statement and
0:49
then start up your application again.
0:53
The process is clumsy and cumbersome.
0:56
[SOUND] Which leads me to another issue.
0:58
When you write a console.log statement,
1:01
you're adding code to your application
that you don't actually need.
1:03
Your program doesn't require
the console.log statements to function.
1:07
In fact, committing the console.log
statement to version control, isn't
1:11
only frustrating to you but it may confuse
other developers working on your project.
1:15
Having seemingly random values logged
out to the terminal raises questions,
1:20
like what does this mean?
1:24
Or, is this supposed to be here?
1:26
In general,
console.log can be problematic and
1:28
you can overcome these problems
by using proper debugging tools.
1:31
[SOUND] Most environments have debugging
tools that allow you to do a couple of
1:35
important things.
1:39
[SOUND] Firstly, it allows you to
pause the execution of your program at
1:39
specific points in the code.
1:44
This allows you to inspect
the contents of variables and
1:46
modify their values while
the program is still running.
1:49
The application we'll be
debugging is available on GitHub.
1:54
I'll include the command to git
clone it down to your local machine.
1:58
It's an express application that was
generated with the express generated
2:04
command line tool and has been modified.
2:07
After you've installed all
the dependencies with npm install,
2:10
you can start your
application with npm start.
2:15
If you visit localhost:3000 you see
the application called Reversify.
2:20
And it can reverse any string and
it gives some examples.
2:25
If I click on joel, it says blank
2:30
reversed is leoj the original
string is missing.
2:34
We'll debug the application to see
where our application is breaking.
2:40
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up