In this video you're going to create and run your very first note J s script.
Now we're gonna keep it simple for the moment.
This is actually the last video in this little getting setup section in the next section which starts
in the next video.
We'll move on to explore node in detail and we'll start to build out meaningful applications.
For now the goal is to just give us a place to even put our code.
And we're gonna figure out how to run our scripts.
Let's go ahead and kick things off by actually closing down the terminal the terminal or the command
prompt on Windows is not something we're gonna use throughout the rest of the class.
Instead I will be using the integrated terminal built right into visual studio code so we don't have
to switch between windows.
I'm going to close that down and let's just get a bit organized on the left hand side.
I'm gonna put the browser that's where this will stay for the rest of the class and on the right hand
side.
I'm going to put Visual Studio code.
Now the goal is to give us a place to put all of the files and folders will end up creating for our
projects throughout the class.
Right here I'm going to expand the Tree View and you'll notice that there is no folder open so let's
go ahead and create one and then we'll open it.
I'll be using the file explorer for my operating system which is the finder to create a new directory
and you could put that directory wherever you wanted to.
I'm going to put mine right on the desktop.
So right here on the desktop I'll be creating a new folder and I'm going to call this something like
node hyphen course.
Perfect.
This is the location where we're going to put all of the stuff we write in this course.
And this is the folder we're gonna open up in Visual Studio code.
I'm gonna shut down the binder and open up that directory right here on the desktop.
I have my node course folder which I'll double click.
This is going to open up that directory in Visual Studio code which I can see based off of the window
title and the folder title over here.
Now we can actually add files and folders to this directory to build out our projects.
Now as I mentioned we're going to keep things pretty simple in this video.
We're gonna have a one line script just to make sure everything is working correctly.
So let's go ahead and create it right here in the node course folder I'm going to create a brand new
file and we can call this whatever we like.
I'm going to call it something like Hello Dot J S.
Remember no J S isn't a programming language.
In the end of the day all the code we write is javascript code.
So right here I'm using a dot J.S. extension exactly like I would if I was creating JavaScript files
that I intended to run in the browser as the first and only line in this file.
We're going to use console dialog to print a message to anyone who runs the script.
So right here we'll be accessing the console object.
We'll be using the log method on there calling it as a function and passing in a single argument right
here.
That is the string something like Welcome to the class.
Now you should be familiar with all of this since the basics of JavaScript are indeed a pre req for
this class.
And there we go.
We now have a simple node script.
Now you might say hey this really isn't a node script.
This is a regular old JavaScript script but it's important to note that console dot log it's not actually
part of the javascript programming language.
This is always part of the runtime.
Whether that comes from a browser like Chrome or node j s so there's no better time than now to show
you where the node docs live over at node j s dot org.
We have this docs page up top on the left hand side.
I have two API pages for the two versions showing on the home page.
I'll click on mine then down below.
I have a long list of different modules we can work with this one the one that we just use is called
console.
I'm going to expand that and what do we get.
We get all sorts of different ways we can use console and down the list.
We do have the one that we just used.
Console dot log so the documentation for node is a great way to get comfortable with the features and
we'll be referring to it a lot throughout the rest of the class.
Right here though we can see that console dot log is something provided by node.
And if I click that it brings us down to some examples as to how we can use it.
Now let's go ahead and actually run our script to see our little message print to the screen then we'll
be done with this video.
As I mentioned we are going to use the integrated terminal throughout this class and makes it really
easy to run terminal commands from right inside a Visual Studio code and you can find it by going up
to the terminal menu and clicking new terminal also take a moment to note the keyboard shortcut.
I'm a huge fan of keyboard shortcuts.
So for me on a Mac it is control Tilde.
I can just type that from anywhere to crack open a new terminal.
And here I have it.
Now we're already navigated to the correct location.
Here I'm running commands from inside of the node course folder and you should see that as well.
And what we're going to do is use that node command once again.
Now in the past we had used node just like this to run individual statements.
When we have a script we want to execute.
We use space and then we provide that script name.
So right here node space Hello J S matching up with the file name we created.
Now we can actually execute this little node application by hitting enter to run it.
And what do I get.
I get my message.
Welcome to the class printing.
And this is fantastic.
That's where we're going to stop for this one.
We now have a place to put our projects and our project files and we know how to run a node scripts.
So we're done with this video and we're done with this section in the next section.
We're going to dive in and start to learn how to use know j asked to build out back end and server side
applications.
I am beyond excited to get to it.
So let's go ahead and jump into the section introduction for the next one.