1. app 폴더


기존 src 폴더를 app으로 이름을 변경한 뒤, 내부에 src폴더를 생성하고 그 밑에 routes와 views를 넣는다.

이에 맞게 코드를 수정한다.

Untitled

app.js


"use strict";

//모듈
const express = require("express");
const app = express();

//라우팅
const home = require("./src/routes/home");

//앱 세팅
app.set("views", "./app/src/views");
app.set("view engine", "ejs");

app.use("/", home);

module.exports = app;

package.json


{
  "dependencies": {
    "ejs": "^3.1.8",
    "express": "^4.18.1",
    "nodemon": "^2.0.19"
  },
  "name": "login-lecture",
  "version": "1.0.0",
  "main": "app.js",
  "bin": {
    "login-lecture": "bin/www.js"
  },
  "scripts": {
    "start": "node ./app/bin/www.js",
    "test": "echo \\"Error: no test specified\\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "description": ""
}

서버가 잘 구동되는지 확인한다.

잘 되었다면 git add, commit, push를 진행한다.