node.js 4

[node.js] AWS SDK사용하여 S3 버킷에 업로드하기

참고 사이트 : https://aws.amazon.com/ko/sdk-for-node-js/ 예제 코드 aws-sdk 라이브러리를 활용하여 파일 경로에 해당하는 파일을 s3 로 업로드한다. AceessKey 는 s3 upload 권한을 가져야 한다. const AWS = require('aws-sdk'); const fs = require('fs'); const path = require('path'); const accessKeyId = ''; const secretAccessKey = ''; const region = 'ap-northeast-2'; const bucket = ''; const s3 = new AWS.S3({accessKeyId, secretAccessKey, region}); con..

node.js 2020.04.06

[node.js] node.js 로 생성한 스크립트를 서버 내 daemon 형태로 실행하기

[node.js] node.js 로 생성한 스크립트를 서버 내 daemon 형태로 실행하기[node.js] node.js 로 생성한 스크립트를 서버 내 daemon 형태로 실행하기1. 배경2. 설치 3. 사용 방법1. 배경node.js 로 실행한 코드를 콘솔로 접속하여 실행할 시 콘솔 접속 후에는 해당 프로그램이 종료된다.cronjob 과 같은 배치성 프로그램을 daemon 형태로 지속 실행하기 위해서 forever 란 패키지를 이용해야한다. 2. 설치 npm으로 forever 패키지를 설치한다.서버 내 공용으로 사용될 예정으로 global 옵션인 -g 를 적용한다. $ npm install -g forever3. 사용 방법forever command 를 이용하여 node.js 코드를 실행한다. 사용 가..

node.js 2019.03.04

[node.js] node.js 로 REST API 구축하기 위해 필요한 모듈 리스트

[node.js] node.js 로 express 서버 구축 시 필요한 모듈 리스트[node.js] node.js 로 express 서버 구축 시 필요한 모듈 리스트1. express설치법사용법 2. nodemon설치법 사용법3. joi설치법사용법4. helmet설치법사용법5. morgan설치법사용법실행 결과6. config설치법사용법실행 결과7. winston설치법사용법실행 결과1. expressexpress 는 node.js 에서 web 서버 구축을 위해 꼭 필요한 모듈이다.설치법$ npm install express --save사용법 const express = require('express') const app = express() ​ app.get('/', (req, res) => { res.s..

node.js 2019.02.21

[node.js]node.js 실행 시 events.js:183 throw er; // Unhandled 'error' event 에러가 발생한 경우

node.js 실행 시 events.js:183 throw er; // Unhandled 'error' event 에러가 발생한 경우node.js 실행 시 events.js:183 throw er; // Unhandled 'error' event 에러가 발생한 경우1. 현상2. 원인 및 해결방법1. 현상node app.js 실행 시 events.js 에서 Unhandled 'error' event 에러 발생1❯ node app.js2events.js:1833 throw er; // Unhandled 'error' event4 ^5​6Error: listen EADDRINUSE :::88887 at Object._errnoException (util.js:992:11)8 at _exceptionWithHo..

node.js 2018.09.24