nodejs 에서 js 파일 실행하는데 오류가 납니다.

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
nodejs 에서 js 파일 실행하는데 오류가 납니다.

QA

nodejs 에서 js 파일 실행하는데 오류가 납니다.

본문


function LivechatServerConfig(){
    this.db = new (() => { // db 설정
        this.host      = '127.0.0.1';
        this.port      = 3306;
        this.user      = 'root';
        this.password  = '1234';
        this.dbname    = 'test';
        this.charset   = 'utf8';
    })();
    this.main = new (() => { // 기본 설정
        this.port = 1121;
    })();
    this.table = new (() => { // 테이블 이름
        this.prefix  = 'g5_'; // 테이블 접두사
        this.member  = this.prefix+'member';
        this.livechat = this.prefix+'livechat';
        this.banlist = this.prefix+'livechat_banlist';
    })();
}
module.exports = new LivechatServerConfig();

 

오류가 발생하는 소스는 위 소스이고

 

서버에서 실행시

 

3034868304_1605435313.4185.png

 

이런 오류가 나옵니다.

 

3034868304_1605435348.2032.png

 

유효성 검사시 이 부분이 오류라는데

어떤 부분을 수정해야할까요?

 

항상 감사합니다!

 

 

 

 

이 질문에 댓글 쓰기 :

답변 3

소스에서 new 가 잘못쓰인것같습니다.

 this.db = (() => { // db 설정

이렇게 하시면 될것같습니다.

https://opentutorials.org/course/3347/21185

를 참고해보세요

 

https://poiemaweb.com/nodejs-mysql

 

여기를 봐도 

접속시에 함수(메소드)내에서 db connection 처리가 좀 다른것 같습니다.


function LivechatServerConfig(){
    this.db = new function(){
        this.host      = '127.0.0.1';
        this.port      = 3306;
        this.user      = 'root';
        this.password  = '1234';
        this.dbname    = 'test';
        this.charset   = 'utf8';
    }();
    this.main = new function(){
        this.port = 1121;
    }();
    this.table = new function(){
        this.prefix  = 'g5_';
        this.member  = this.prefix+'member';
        this.livechat = this.prefix+'livechat';
        this.banlist = this.prefix+'livechat_banlist';
    }();
}
module.exports = new LivechatServerConfig();

 

이렇게 해보세요

답변을 작성하시기 전에 로그인 해주세요.
전체 0
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT