This repo is intended to teach web dev early learners how to easily deploy their web apps on repl.it while giving them some experience on using the npm
to manage the build and deploy.
repl.it is a free hosting service which can make our web app available to the public through a public domain accessible from any web browser in the world.
The node package manager helps us add important "packages" to our application so that we can create a server. In this example, we will be using express
to serve our app.
The server is basically a javascript program which we will write in order to allow our index.html
to be accessible through the browser.
Packages are programs (codes) written by other people with the goal of saving us some work. Packages provide us with functions that perform tasks which are either too difficult or too repetitive for us to code. In this case, express
will be responsible for creating a server where our application will run.
- Create a sample html in
index.html
, it can be just a 'hello, world' or another app you'd like to deploy. - We need
npm
to complete this job, so you'll need to have it installed in your system. - Once we have
npm
installed and ourindex.html
file ready, move to the folder where you want to keep your app and runnpm init
- in Linux. - After that, we need to install express. Run
npm i express --save
in the same terminal. - Our project folder now must have 2 new files:
package.json
andpackage-lock.json
- they're the files that keep track of what packages we add to our project. - Open
package.json
and find thescripts
key. By now, there must be only thetest
key inside. - Add a script to
scripts
aftertest
calledstart
, the value should benode server.js
- we'll create the server next.
- Create a file in your project's folder called server.js.
- Import the express package:
const express = require('express');
. - Create an app to hold the server:
const app = express();
. - Export the server to the whole application:
export default app
.