See the Installfest project for more instructions.
Software:
Accounts:
If you do not have these, RAISE YOUR HAND!
In this class, you will learn about:
Follow along online! Put a browser pointed at this site on one side of your screen, and Terminal on the other.
The best way to learn is to teach.
- Latin proverb
Generally, code is something that stands for something else.
Specifically, source code is a series of instructions that tell a computer what to do.
With computers, "code" is not about secrets -- it's about symbols.
"The only perfect program is an empty file." - Alex
When you are coding, you are not baking cookies; you are writing a recipe for how to make cookies.
Writing a recipe involves trying out the recipe (baking a test batch), then tweaking the recipe and trying again and again until you get it right.
(recipe from popcornpottery.com)
If your code is a two-year-old child, then an error is a temper tantrum.
(It can take effort to figure out the underlying reason why they're upset and fix it.)
See also: What went wrong? from MDN
to open your Terminal:
{bash::bash}
C:\Users\yourname
cmd.exe
or PowerShell
) -- but beware, the commands are slightly different than in bashImportant: make your terminal as tall as possible and don't overlap windows
$
or >
symbolnode
-- that's you commanding the computer to launch node
>
prompt1 + 1
2
An "engine" is a type of program that either executes or empowers other programs.
NodeJS (aka node
) is an engine that runs JavaScript programs -- either from files, or interactively from the command line.
WARNING: Before you start typing, look at the prompt!
Davids-Macbook-Pro:~ David$
(Mac)[email protected]:~$
(Ubuntu Linux)C:\Users\david>
(Windows)>
From inside node
, if you want to get back to the shell...
.exit
and Enter
From now on, whenever you see text in the code font
, try typing it into the terminal and see what happens! For example:
'pod' + 'cast'
If that doesn't print 'podcast'
, look at the prompt; you may be inside your shell instead of inside node.
code
directory inside your home directorycode
for each lesson or project
> WARNING: On some windows systems, Command Prompt will open to C:\Windows\System32
WARNING: On some windows systems, Command Prompt will open to
C:\Windows\System32
. You can get back to your home directory by typingcd %HOME%
when you type ls
("list") it shows the contents of the current directory
dir
insteadif you type ls -al
("list all long") it also shows hidden files and extra info like the modification date
dir /A:SH
insteadmkdir
("make directory") it creates a new subdirectory inside the current directorymkdir code
cd
("change dir") moves you into a different directorycd code
would move you into a subdirectory named code
cd
all on its own and press the return key. This will send you back to your home directory.
> Unix shell only, not Windows!pwd
("print working dir") -- shows the name of the current directorycd
("change dir") -- move into a different directoryls
("list") -- shows the contents of the current directorymkdir
("make dir") -- creates a new subdirectory inside the current directoryThese apply to Mac / Unix / Linux / bash / cmder
cd
("change dir") -- With no directory, it lists the current directory. Otherwise, it changes to the specified directorydir
("directory") -- shows the contents of the current directorymkdir
("make dir") -- creates a new subdirectory inside the current directoryThese apply to Windows / DOS / PowerShell
mkdir code
cd code
pwd
cd
ls
(and note that it's empty)
dir
node
and then the name of the source file, like this:$ node hello.js
Hello, World!
code
subdirectory using pwd
or cd
code .
("code dot")hello.js
using the File > New menuInside this file, put the following source code:
console.log("Hello, World!");
Save the file
Switch back to the terminal (using Alt-Tab or Cmd-Tab or clicking)
(If you are using VS Code, you can click Terminal → New Terminal for the built-in terminal panel)
Run this file using node hello.js
What happens? Is this what you expected?
These work in bash
:
Also:
node h
Tab will emit node hello.js
)(image source: Clément Chastagnol)
/