-
간단한 web server (express)Develpment/Node.js 2020. 9. 13. 21:31
1. express ( http://expressjs.com/ko/starter/installing.html )
* express 설치
$ npm install express --save
* save 옵션으로 인해 package.json 에 추가
1234567891011121314{"name": "section01","version": "1.0.0","description": "npm project","main": "index.js","scripts": {"test": "echo \"Error: no test specified\" && exit 1"},"author": "","license": "ISC","dependencies": {"express": "^4.15.3"}}cs
* node_modules 폴더 생성됨.* app.js 파일 생성
123456789var express = require('express') // express 모듈 로드var app = express()// 3000 포트로 웹서버 실행app.listen(3000, function() {console.log("start! express server on port 3000!")});cs * 실행 명령어
$ node app.js
'Develpment > Node.js' 카테고리의 다른 글
static 디렉토리 설정 (express) (0) 2020.09.13 URL Routing 처리 (0) 2020.09.13 nodemon (0) 2020.09.13 NPM Project 생성하기 (0) 2020.09.13