본문 바로가기

[프로젝트] 냥냥곰펭

[BE] 0-1. 프로젝트 준비 (Node.js / Express / Babel / Nodemon / MySql / Sequlize / ESLint / Prettier)

1. Node.js + Express 설치

- Express 사용 이유 : Node.js를 사용하여 쉽게 서버를 구성할 수 있게 만든 클래스와 라이브러리의 집합체

(참고1) https://dion-ko.tistory.com/123

(참고2) https://soohyun6879.tistory.com/155 

(참고3) https://despiteallthat.tistory.com/139

npm init -y

npm install express

npm install ejs

 

2. babel 설치

Node.js가 Javascript의 모든 최신 문법을 이해하는 것이 아니기 때문에 작성하는 최신 문법을 구 문법으로 변경하여 Node.js가 이해할 수 있도록 도와주는 역할

(참고1) https://blog.naver.com/tbaram10/222636000643

(참고2) https://www.daleseo.com/js-babel-node/

(참고3) https://velog.io/@jiheon/Node.js-Babel

npm i -D @babel/core

npm i -D @babel/cli

npm i -D @babel/preset-env

npm i -D @babel/node
i는 install의 줄임말, -D는 --save-dev의 줄임말
"npm install @babel/core --save-dev" 와 같음

 

3. nodemon 설치

- 프로젝트 폴더의 파일들을 모니터링하고 있다가 파일이 수정되면 서버를 자동으로 restart 시켜주는 패키지

(참고1) https://velog.io/@chy0428/Node-JS-Nodemon-%EC%84%A4%EC%B9%98

npm install nodemon --save-dev

- 오류 발생 : nodemon까지 설치 후 아래와 같은 에러 발생

Warning: To load an ES module, set "type" : "module" in the package.json or use the .mjs extension.

- 해결 : package.json 파일에 "type": "module"  을 추가

(참고 : https://yoo11052.tistory.com/54)

 

 

4. mysql + Sequlize(시퀄라이즈) 설치 : 설치가 안 된 것 같아서 다시 할 예정,, 😥

- Sequlize(시퀄라이즈) : 자바스크립트의 객체와 데이터베이스를 연결해주는 도구

- 시퀄라이즈로 MySQL 연동하기

(참고1) https://lgphone.tistory.com/86

5. ESLint / Prettier 설치 : 설치가 안 된 것 같아서 다시 할 예정,, 😥

- ESLint : 자바스크립트의 문법을 확인해주는 도구 (코드의 에러와 문제점 검사 후 고쳐줌)

- Prettier : 코드의 모습을 예쁘고, 읽기 좋게 만듦

(출처1) https://defineall.tistory.com/666

(출처2) https://velog.io/@rimo09/ESLint-%EC%84%A4%EC%A0%95

 

[230613] app.js

[230613] views/test.ejs