Always bet on JavaScript.
Visualisation of npm dependencies by @anvaka.
Before you start you'll probably want to read a bit about Node, the JavaScript engine, and client vs. server-side. We'll cover this in the lecture but make sure you fully understand these concept, the resources below can help.
- Introduction to Node.js
- Differences between Node.js and the Browser
- The V8 JavaScript engine
- The Fundamentals - Server Side
- The JavaScript engine visualized
🎦 Watch a video about the browser versus Node.js.
🎦 Watch a video about Modules.
You can do these exercises before you start working on the assignments to get comfortable with the topics covered in class. The below workshoppers are interactive, self guided lesson modules, from NodeSchool.
- Learn the basics of Node (workshopper)
- How to NPM (workshopper)
- The basics of Express.js (workshopper)
- freeCodeCamp - Managing Packages with NPM (exercises)
- freeCodeCamp - Basic Node and Express (exercises)
Learn the basics of node modules and npm packages and setup a boilerplate for your own feature.
- Time: 4:00h
- Goals: subgoal 1, subgoal 2
- Due: before week 2
-
Create the boilerplate for the node app you are going to create. Include a
package.json
with a correct name, version, dependencies, and other metadata. See npm’s documentation onpackage.json
. For examples ofpackage.json
files, seerepeat-string
,longest-streak
, orskin-tone
. -
Look trough the NPM registry and install a package from npm that would be helpful for your job story and try it out in
index.js
. Not sure what package to pick? You can try playing around withcamelcase
orlodash
to get comfortable requiring packages and using them. -
Improve the developer experience of your application. Look for so called 'developer dependencies' on NPM.
nodemon
is a good example, it will monitor for any changes in your source and automatically restart your server. Perfect for development. -
Create some
run scripts
in yourpackage.json
to start, serve or build your application.
Ask yourself upon completion:
- How does
require
work under the hood? - What's the difference between
dependencies
anddevDependencies
? - What are the differences between
global
andlocal
dependencies? - What tasks can you run with
npm run scripts
?
Additional resources
🎦 Watch a video about Node Packages.
🎦 Watch a demo about NPM.
In this assignment you’ll build a static file server with a little help from Express.
- Time: 4:00h
- Goals: subgoal 1, subgoal 2
- Due: before week 2
Create a server that handles routes and serves static files in Node.js. Feel free to write your server from scratch if you feel adventurous, otherwise express
is your best option.
- Have a couple of different
routes
(e.g./about
/contact
) - Respond with a
404 Not Found
if you go to a route that doesn't exist. - Serve
static files
such as JavaScript and CSS but also media files such as images
Ask yourself upon completion:
- How does the
app instance
work? What makes it possible you can do things likeapp.get
orapp.listen
? - What are the
req
andres
parameters? - The confusing part is that your laptop is both the client and the server. It's a
local development
environment.
Additional resources
-
Push your changes:
Hand in your progess in your repository on GitHub under your username. -
Create an issue:
Mark this assignment as complete by opening an issue on our GitHub issue tracker. Fill in the issue template with the correct information. Include what you did in the description of the issue. -
Feedback:
Let us know what you thought of the homework, what part you spend a lot of time on and give us any feedback. Your project will be reviewed and receive feedback, so expect people to read it, and be ready for tips and tops!