The files contained here are the foundation of a one to many (and many to one) realtime web app.
We are using express.js to serve out our static HTML files and using socket.io to handle real-time communication and messaging Through this combination we can have realtime communication across many devices.
In this example we create an emoji sharer where when we click on a screen position, we replicate an emoji in that position on everyone's screen who is connected.
- coming soon
pwd
: present working directorycd
: change directory : cd /Desktopls
: list filesls -al
: list all files with infotouch
: makes a new file : touch index.htmlmkdir
: make directory : mkdir my-directory-namectrl + c
: to exit things
-
rm
: remove : rm /path/to/file * no warning! -
rm -rf
: remove directory : rm /path/to/directory * no warning! -
sudo
: super use do : do some command with root privileges * scary because it really do anything.
node -v
: what version of node am I using? / is it loaded?node
: run a node application : usually with a file path like:node server.js
npm
: node package manager, install packages/plugins for node (other peoples code so we don't have to write as much)npm install --s package-name
npm init
: start a new node project and generate a package.json file
cd
into your project directorynode app.js
to use node to boot up your app.js file on the server- point your browser to
localhost:3000
and verify that everything is working
- download the .zip of, or
git clone
this project cd
into the downloaded project folder- run
npm install
node app.js
- gogogadget!
mkdir
/ make a new project foldercd
into the new project foldernpm init
- Follow the prompts, but change
index.js
toapp.js
for later clarity - make an
app.js
file inside the project folder - make a
public
folder - inside the public folder, make
index.html
,main.css
, etc. - install dependencies (
--save
will automatically add the dependencies in yourpackage.json
file)npm --save install socket.io
installs our web socket frameworknpm --save install express
installs our web server framework
- checkout the socket.io / express.js example to get started with these files