w01 Node

a00 walkthrough + Node.js setup

2022-01-18T15:30:00-05:00

  1. Installing Node with NVM
  2. Setting up SSH key authentication
  3. Accepting assignments
  4. Cloning a repository
  5. Getting started with NPM
  6. Write and edit some HTML
  7. Using browser-sync
  8. Write and edit some HTML
  9. Ports for testing
  10. Adding, committing, and pushing your changes
  11. Troubleshooting the output from autograders on GitHub

Notes

Installing NVM

If you install NVM using the supremely straightforward instructions linked below, don’t make the mistake of over-thinking it the way that your instructor did today.

The only reason that it did not work was that I needed to exit and reload the terminal OR I could have run source ~/.bashrc and it would have reloaded my path so that the nvm command would run properly. I just didn’t read the next set of instructions about doing exactly that.

So, learn from my mistakes.

I’ll demo NVM on Thursday and we can troubleshoot a version mismatch issue.

Ports

Similarly, the issue that I had displaying a test page served by browser-sync would have been easily dealt with if I had thought about it for a minute.

When I set the firewall up initially, it was to serve only to requests coming from high-number ports from a specific address (the address in my home) and I forgot about that immediately after doing it, of course. So that is fixed now and we’ll be able to proceed with demos.

If you are interested in learning more about what ports do for us, see the link below.

Also, if you are interested in learning to set up a remote server for running things like this, I can post a tutorial. It is relatively easy and nice to have some experience working on remote servers.

a00 instructions

Installing Node with NVM

https://code.visualstudio.com/docs/editor/github

Adding a new SSH key to your GitHub account

The W3C Markup Validation Service

HTML <th> scope Attribute

Service Name and Transport Protocol Port Number Registry - IANA

TCP/IP Ports and Sockets Explained - Steve’s Internet Guide

What is a computer port? | Ports in networking - Cloudflare

Running JS with Node

2022-01-18T15:30:00-05:00

  1. Running JS in a command terminal
  2. Structuring an NPM package
  3. Node console.log()
  4. Scripting and dependencies
  5. const
  6. Arrow functions

Slides

https://comp426-2022-spring.github.io/slides/w01-01.html

Introduction to Node.js - Node.js

JavaScript Tutorial - w3 schools

JavaScript Variables – A Beginner’s Guide to var, const, and let - Madison Kenna

Arrow functions for beginners - Brandon Morelli

Notes

In class today, I was trying to set environment variables so that we could see what happened when we used one instead of letting the basic webserver use its default, but setenv wasn’t working.

This is because setenv doesn’t belong to bash. It belongs to a different shell. I was recently working on a system using tcsh instead of bash and those commands got stuck in my head.

The correct commands for setting (and viewing) an environment variable called PORT are below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# `export` will set an environment varialble
export PORT=5000

# If set, the following should give you the value saved in the variable:
echo $PORT

# To see an environmental variable you can call `env` and pipe it through `grep`
env | grep PORT

# `env` without any options will put ALL environment variables into STDOUT.
env

# `env` will set a variable similarly to `export` above and then put all environment variables into STDOUT
env PORT=5000

# You can un-set a variable with `env` as well
env -u PORT
env --unset PORT