대표적인 javascript 런타임 node.js를 사용하면 자바스크립트 개발자가 웹 서버 개발까지 할 수 있다. 또 node.js로 빠르게 웹 애플리케이션을 개발함으로써 유지보수 비용을 절감하고 개발 생산성도 향상된다!
node.js의 프레임워크이다. 자바스크립트 프레임워크로 React, 자바 프레임워크로 Spring 등등이 있는 것처럼 Express는 node.js를 빠르고 간결하게 사용할 수 있게 해준다.
(당연히 node.js가 설치되어 있는 환경임을 가정한다.)
참고: https://expressjs.com/의 공식문서
npm init
//package.json 파일을 작성한다
npm install express --save
//디렉토리에 Express를 설치하고 dependencies 목록에 추가한다.
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('hello world');
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
node app.js
http://localhost:3000/로 서버가 실행된다!
npm install express-generator -g
express --view=pug myapp //myapp이라는 이름의 express 앱을 생성
디렉토리 구조는 다음과 같다.
cd myapp
npm install
npm install을 꼭 해주어야 한다.
DEBUG=myapp:* & npm start