Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
How does JavaScript run on a web server? Usually it's with Node.js. Node is a cross-platform runtime environment for JavaScript. Since Node provides a way to run JavaScript outside of the browser, you can use it to build anything from command-line tools, to frameworks, web servers, and more.
Client side JavaScript is
executed by the browser,
0:00
server side JavaScript is
executed by a web server.
0:03
So how does JavaScript
run on a web server?
0:06
Well usually it's with node.js.
0:08
Node allows developers to do
much more with JavaScript than
0:10
just making websites interactive.
0:13
Node is a cross platform
runtime environment for
0:16
developing server-side
applications with JavaScript.
0:18
Since Node provides a way to run
JavaScript outside of the browser, you can
0:22
use it to build anything from commandline
tools to frameworks, web servers and more.
0:25
Node.js is based on Google Chrome's V8
open source JavaScript engine.
0:29
Even though the Chrome browser and
0:35
Node use the same JavaScript engine, they
are two different run time environments.
0:37
As you learned in the previous video,
0:41
Node supplies JavaScript a different set
of host objects compared to the browser.
0:43
Host objects like http, https,
fs for file system, url,
0:48
os, and others are available to JavaScript
to allow it to run outside the browser.
0:53
Where Node really shine is in
building real-time multi-user
0:57
applications that handle many events or
user actions at the same time.
1:01
Like tap apps for instance, also
multi-player games, collaboration tools,
1:06
video-conferencing apps and more.
1:10
One of the best parts about Node is its
driving ecosystem of free-open source
1:14
tools.
1:18
Npm, the node package manager, allows for
the sharing and reuse of code and
1:19
software written by other developers
in the JavaScript community.
1:24
Npm is the largest package ecosystem
in the world with over 700,000
1:27
packages available to help developer
set up and build awesome projects.
1:33
In addition,
developers often use npm as a task runner
1:37
to help automate repetitive tasks and
most of their built tool chain.
1:41
Now, since Node is a runtime environment,
it does little out of the box,
1:45
so to make it easier to get setup and
1:50
working with Node,
developers often use a Node framework.
1:52
And one of the most popular
frameworks is Express.
1:55
Node and Express go hand in hand.
1:58
Express, allows developers to build
scalable feature rich applications,
2:01
websites and more, on top of Node.
2:05
Express provides built in tools and
functionality to take care of common tasks
2:08
like routing or
handling requests at different URL paths.
2:13
Also serving static files and
dynamic templating to render HTML pages.
2:17
Developers can also build
REST API's with Express and
2:22
simple servers that talk to browsers.
2:26
As you've learned, Node is a powerful
tool that can run JavaScript
2:29
applications on both the server side and
client side.
2:32
Without Node, the modern landscape
of JavaScript probably wouldn't be
2:35
as flourishing and as exciting.
2:38
Be sure to have a look at the teacher's
notes to see some of the awesome
2:40
things you can build with Node and
Express.
2:43
You need to sign up for Treehouse in order to download course files.
Sign up