Node.js Crash Course Tutorial #1 - Introduction & Setup — Transcript
Full transcript
- 0:00hey gang and welcome to your very first
- 0:01step in becoming a node ninja a rather
- 0:10than gang now I do already have a node
- 0:12tutorial on this channel but I wanted to
- 0:15update it because now that's about four
- 0:17or five years old so I wanted to do a
- 0:20quick refresh a nice new node tutorial
- 0:22because in the future I'm going to
- 0:24create some more advanced node tutorials
- 0:27as well and then I can direct people to
- 0:29this more recent playlist to learn the
- 0:32basics first of all okay there so first
- 0:34things first what is node j/s well as
- 0:38developers when we're creating websites
- 0:40we normally talk about code on either
- 0:42the front end inside browser or back end
- 0:45code or server-side code which is the
- 0:47code which runs on a server now
- 0:49javascript is normally confined to run
- 0:52in a browser in the past on the front
- 0:54end and we'd use it to do things like
- 0:56add interactivity to a web page like
- 0:58click events or things like that now we
- 1:00never used to be able to run JavaScript
- 1:03directly on a computer or server but
- 1:06node allows us to run JavaScript on the
- 1:09server side as well or even directly on
- 1:11computers now before you explain any
- 1:14more about that first of all I want to
- 1:16talk a little bit about how computers
- 1:18actually understand code so computers
- 1:21really only understand machine code but
- 1:24that is really complex to write and a
- 1:27read
- 1:27it's like binary like this so something
- 1:30called assembly language is built on top
- 1:33of that which is a bit easier to read
- 1:35and write which is then assembled down
- 1:38into machine code so the computer can
- 1:40still understand it but this right here
- 1:43this assembler language is still overly
- 1:45complex to read and write so built on
- 1:47top of that we have programming
- 1:49languages like C++ which are abstracted
- 1:51a lot away from assembly code and
- 1:54they're much easier to read and write so
- 1:58ultimately this C++ code is then
- 2:01compiled down to machine code so
- 2:05therefore we can write C++ code on a
- 2:07computer and a computer will understand
- 2:09it because it's being compiled down to
- 2:11machine code now
- 2:13javascript is a language which is
- 2:15abstracted even more away from machine
- 2:17code than C++ to make programming easier
- 2:20still but computers cannot directly
- 2:23understand JavaScript or compile it down
- 2:25to machine code so we cannot directly
- 2:27run JavaScript on a computer right but
- 2:31it can run inside a browser so how does
- 2:33that work well running inside browsers
- 2:36is an engine called the v8 engine and
- 2:38the v8 engine is written in C++ by
- 2:42Google and it compiles JavaScript into
- 2:44machine code at runtime so bypassing
- 2:47JavaScript code through this v8 engine
- 2:50in the browser the computer can then
- 2:52understand JavaScript within the context
- 2:55of that browser however it cannot run
- 2:58JavaScript outside the browser because
- 3:00there is no v8 engine compiling it down
- 3:02outside the browser it's confined to the
- 3:05browser only but that is where node
- 3:07comes into play so node.js is a program
- 3:11also written in C++ and that wraps the
- 3:15v8 engine so this v8 engine that's in
- 3:18browsers also lives inside node as well
- 3:21now because node is written in C++ it
- 3:26can run directly on our computer so by
- 3:29installing and running node on our
- 3:31computer it can take our JavaScript it
- 3:34can run it through the v8 compiler that
- 3:36it has inside it and it compiles our
- 3:38JavaScript into machine code so that in
- 3:41essence we can now run JavaScript
- 3:43directly on a computer or server and not
- 3:46just in a browser but node is more than
- 3:51just a wrapper for the v8 engine
- 3:53it also hooks into the v8 engines and
- 3:55more functionality to JavaScript so that
- 3:58when we are using nodes a compile and
- 4:00run JavaScript we can use all of this
- 4:02extra functionality in our JavaScript
- 4:04code and that kind of functionality
- 4:05includes things like the ability to read
- 4:08and write files on a computer or to
- 4:11connect to a database the ability to act
- 4:13as a server for content these are all
- 4:16the kind of things you'd expect a
- 4:17server-side language to do and now we
- 4:19can do them with JavaScript running
- 4:22through node now remember javascript was
- 4:24originally made for the brow
- 4:26to add interactivity and not to run
- 4:29directly on computers or service so
- 4:32normally it can't do all of this stuff
- 4:34but with the help of node it can but on
- 4:36the flip side since we're now using node
- 4:38to run JavaScript outside the browser we
- 4:41lose access to JavaScript features such
- 4:43as the document object model we can't
- 4:45interact with HTML elements anymore but
- 4:48we don't really need to do that when
- 4:50we're running JavaScript on a server and
- 4:51acting as a back-end to our website
- 4:54right so just going back to computers
- 4:57and machine code node now plugs into the
- 5:00top of this stack with the v8 engine so
- 5:04that now we can write JavaScript code on
- 5:06a computer which is then compiled down
- 5:08into machine code forests so that
- 5:11computers can now understand JavaScript
- 5:14and that is freaking awesome
- 5:19so then now we've got a bird's-eye view
- 5:21of what node actually does for us what
- 5:24would we actually use it for well the
- 5:27role of node in a website is basically
- 5:29to run JavaScript on the back end or
- 5:31server side and then we're going to be
- 5:32handling requests coming in from a
- 5:35browser so for example a user might
- 5:37visit your website in a browser now that
- 5:39browser is going to make a request to
- 5:41the server the node server is going to
- 5:43run some kind of JavaScript you'll react
- 5:45to the request and it might communicate
- 5:48maybe with a database or files on the
- 5:50server then it's going to formulate some
- 5:52kind of response and send it right back
- 5:55to the browser now that response could
- 5:58be an HTML page with dynamic data
- 6:00embedded inside it or maybe some CSS and
- 6:03image files etc so basically the note
- 6:06server is running JavaScript on the back
- 6:09end to do all of this so using node in a
- 6:12website is pretty much an alternative
- 6:14now to or the server-side languages like
- 6:16Python Ruby PHP etc but the rad benefits
- 6:20of using node over the others first of
- 6:23all if you're already familiar with
- 6:25JavaScript then there's absolutely no
- 6:27need to learn a new server-side language
- 6:29because node is going to be taking
- 6:31javascript and compiling it down so we
- 6:33can use the same language on the front
- 6:35end and the back end and to that end we
- 6:38can also share cold for front end and
- 6:41the back end since they both use
- 6:43JavaScript it's very popular and it's
- 6:45got a massive massive community around
- 6:48it so there's always help if you need it
- 6:50and there's also a huge amount of
- 6:52third-party packages and tools to help
- 6:55with web development and we're going to
- 6:57see some of those as we go through this
- 6:59course
- 7:03I rather than so in this course we're
- 7:05gonna go from the absolute beginning and
- 7:07to begin with I'm going to show you how
- 7:09to install node and use it to run
- 7:11JavaScript on your computer or in a
- 7:13server then we're going to see how to
- 7:15use know to read and write files on your
- 7:17computer we'll also see how to create a
- 7:20server and then make a website using
- 7:22node by listing for and responding to
- 7:24HTTP requests then we're going to dive
- 7:26right into third party packages in
- 7:29particular Express to create an express
- 7:32up and that is a very very easy way and
- 7:35a very popular way to build node
- 7:37websites then we're going to introduce
- 7:39databases in particular
- 7:41MongoDB which is a no sequel database
- 7:44and we're going to use that to store
- 7:46data and then create dynamic web pages
- 7:48and to that end as well we will be using
- 7:51template engines ejs in particular to
- 7:54inject dynamic content into our HTML
- 7:56templates which we can then send back to
- 7:59the browser finally we're going to put
- 8:01everything together that we learn to
- 8:03make a node powered website project so
- 8:07this is the little project we're going
- 8:08to create it's a very simple blog
- 8:11website where we can list all of the
- 8:13current blogs we can click on one to see
- 8:15more information we can also go to add a
- 8:18new blog and I'll just call this one
- 8:20Mario Party and add in some ninja tips
- 8:24as you do like so and then click on
- 8:28submit and we can see that new blog at
- 8:30the top over here we can also delete
- 8:32blogs by clicking on this little Delete
- 8:34icon right here and we have an about
- 8:37page as well which every block needs so
- 8:40this is the project we're going to be
- 8:43creating using node Express and also
- 8:46MongoDB as the database as well
- 8:48throughout this series now before we
- 8:52start I want to make one thing crystal
- 8:54clear this is not a beginner Java Script
- 8:57course and you should already know the
- 8:59foundations of the JavaScript language
- 9:01things like functions how asynchronous
- 9:04code works all that kind of just and
- 9:06ideal it you should also know a little
- 9:09bit about HTML and CSS too since at the
- 9:11end of the day we are making a website
- 9:13and there will be HTML and CSS involve
- 9:17now I've got courses on both of these
- 9:19things on this channel and on udemy I've
- 9:22got a modern JavaScript course and also
- 9:25an HTML and the CSS crash course as well
- 9:27so the links to both of these are going
- 9:29to be a highlight down below
- 9:35a rather than gang so the first step in
- 9:38all this is to install node on your
- 9:41computer now it might be that you
- 9:43already have node installed on your
- 9:45computer but you're just unaware of it
- 9:47so in order to check that open up a
- 9:50terminal I'm going to use command prompt
- 9:53by typing CMD and pressing enter and
- 9:55then in here type node space hyphen V
- 9:58and if you have node installed it should
- 10:01give you back a version number you can
- 10:03see mine is version 14 point 1.0 now if
- 10:08you don't get a version number it means
- 10:09you don't have node installed and you're
- 10:12gonna have to go ahead and install it
- 10:14likewise you might get a different
- 10:16number a smaller number which means you
- 10:18have an older version of node in which
- 10:21case you might want to update as well so
- 10:23in order to do that to install it or
- 10:26update it go to node.js org
- 10:28this link will be down below and then
- 10:30click on this button right here to
- 10:32install the latest version that's going
- 10:34to download an installer run that when
- 10:36it's done and the install wizard will
- 10:39install node on your computer for you it
- 10:41only takes a couple of minutes
- 10:43now once you've done that I would
- 10:45suggest closing your terminal opening it
- 10:47up again and typing in node - V just to
- 10:51make sure you get a version number and
- 10:53it's installed correctly so now you have
- 10:56node installed on your computer we can
- 10:58use it to run JavaScript directly on our
- 11:01computer and we could even do that
- 11:03directly inside this terminal so to do
- 11:06that I'm gonna type node and then enter
- 11:08and that starts the node process and
- 11:10right now we see a blinking cursor and
- 11:12that's asking us to basically type some
- 11:15JavaScript to run through node so now I
- 11:17could write something like 5 plus 5
- 11:19press ENTER and we get back 10 that's
- 11:22valid JavaScript right and we could
- 11:24write any JavaScript code that we want
- 11:25to write here so I could say var name is
- 11:28equal to Mario and then type name and we
- 11:32get back and Mario so any kind of valid
- 11:35JavaScript we can write inside this
- 11:37terminal but ideally we don't want to
- 11:40write code in a terminal all the time
- 11:42it's going to be really tough to create
- 11:43a website this way so instead we're
- 11:46going to need a good text editor to work
- 11:48in now I'm going to be
- 11:50using vs code of Visual Studio code
- 11:52which is a great free text editor and
- 11:55you can get it from code dot visual
- 11:57studio comm and click on this download
- 11:59button right here for Mac or for Windows
- 12:01but you don't have to use this you can
- 12:03use your own favorite like sublime or
- 12:05atom if you prefer but at the minute I
- 12:07would recommend this one it's a really
- 12:09nice text editor so anyway once you have
- 12:12your text editor installed open it up
- 12:15and maybe start a new project folder in
- 12:18that text editor I'm actually going to
- 12:20do that from the command line over here
- 12:22so let me exit this process by clicking
- 12:25ctrl C twice and that exits out of the
- 12:29node process then I'm going to navigate
- 12:32to a folder where I want to create my
- 12:34new project so I'm going to say CD which
- 12:37stands for change directory to dive into
- 12:39a folder called documents that I have on
- 12:43my computer then CD again to go into
- 12:45another folder I created called totes
- 12:46and then right here I'm going to create
- 12:48a new directory by saying mkdir that
- 12:52stands for make directory and I'm going
- 12:54to call this node - crash - course and
- 12:58then I'm going to see the into that so
- 13:01see the node - crash - course and then
- 13:05I'm going to open up this particular
- 13:07directory inside of the S code now to
- 13:10open that up from the command line in vs
- 13:13code I can say code dot and that means
- 13:17open up visual studio code in the
- 13:19current directory alright so press ENTER
- 13:22and that should hopefully open up visual
- 13:25studio code in this project directory we
- 13:28can see that right here in node crash
- 13:29course ok
- 13:33so then now we have our text editor open
- 13:36let's just give this a whirl what I'm
- 13:39gonna do is create a new file over here
- 13:41and I'm gonna call this test dot J s and
- 13:45inside you I'm just gonna write some
- 13:47basic JavaScript code so I'm going to
- 13:49say Const and then we'll say name is
- 13:51equal to Mario right and all I'm gonna
- 13:55do is console dot log name so I've got a
- 14:00JavaScript file now on my computer how
- 14:02do I run this JavaScript file well I can
- 14:05do that through the terminal so I'm
- 14:07going to go to terminal at the top and
- 14:09then go to new terminal and make sure
- 14:11you're in the correct directory where
- 14:14the file exists where you made that file
- 14:16and then type node and then the file
- 14:20name so in our case test now you don't
- 14:23need to add the JavaScript extension
- 14:25because it knows we're going to run a
- 14:27JavaScript file so I can just say node
- 14:30test which is the name of the file press
- 14:32ENTER and it runs that file for us on
- 14:35our computer and we actually see down
- 14:37here in the terminal which is acting as
- 14:39the console for us this name Mario okay
- 14:42so it run the file it logged this to the
- 14:45terminal or the console down here so let
- 14:48me try this again I'm going to change
- 14:50this to something else like not your paw
- 14:53but Yoshi and save that now I have
- 14:56to run this file again for it to work so
- 14:58down here I can just press up to do the
- 15:01latest command I wrote and press ENTER
- 15:03again node test and now we can see Yoshi
- 15:06right here so we could write any
- 15:09JavaScript inside this file then run it
- 15:11and if we're logging things to the
- 15:13console we're gonna see them down here
- 15:14inside the terminal and that's how easy
- 15:17it is to run a javascript file on our
- 15:20computer using node this is not being
- 15:23run inside a browser anywhere now it's
- 15:25being run directly on our computer now
- 15:29finally going i've created course files
- 15:32for every single lesson in this tutorial
- 15:34series and they're all found on this
- 15:37give repo right here node crash course
- 15:39now don't worry if you don't know how to
- 15:42use git or github or anything like that
- 15:44you don't really need to know how to to
- 15:46see the code or down
- 15:47load the code I'll leave this link down
- 15:49below but essentially each lesson in
- 15:52this series is going to have its own
- 15:54branch in this github repo so we can see
- 15:57the branches right here and if you want
- 15:59to see the code for lesson 4 for example
- 16:02you could go to the lesson for branch
- 16:03and you're gonna see all of the code
- 16:05right here and all of the different
- 16:07files now if you want to download this
- 16:10you can go to close or download if
- 16:12you're familiar with github and get you
- 16:14can clone the repo to your local machine
- 16:17or if you want to download a zip file
- 16:19with all of this code in you can do by
- 16:22clicking download zip or right here
- 16:30[Music]
About this transcript
This page contains the full transcript of Node.js Crash Course Tutorial #1 - Introduction & Setup by Net Ninja, generated from the public captions YouTube serves with the video. The transcript has 2,887 words across 390 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.