환경설정 진행 기본환경은 wsl에서 진행하였다. => nodemon환경이 wsl2환경에서 제대로 동작하지 않으니, 그냥 윈도우 환경에서 사용하시는 것을 추천합니다. 설치가 진행되어지지 않아요.
vscode 에서 유용한 패키지들을 추가로 설치
참고링크
Prettier (코드를 이쁘게)
1. 설정
2. save검색
3. Format On Saver(저장 시 자동 포멧적용) 체크 하기.
Material Icon Theme (아이콘을 이쁘게)
Material Theme (테마)
Path Intellisense (경로 찾아줌)
Auto Rename Tag (쌍으로 된 태그 자동 수정)
HTML Snippets (HTML작업할 때 요긴히 쓰임)
CSS Peek (연결된 css선택자로 자동 이동)
Git History (Git 기록을 간단하게 볼 수 있음)
curl -sL deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
npm 명령어 | yarn 명령어 | 설명 |
---|---|---|
npm init | yarn init | 프로젝트 초기화 |
npm install | yarn 또는 yarn install | package.json의 패키지 설치 |
npm install --save 패키지명 | yarn add 패키지명 | 패키지를 프로젝트 의존성 수준으로 추가 |
npm install --save-dev 패키지명 | yarn add --dev 패키지명 | 패키지를 프로젝트 개발 의존성 수준으로 추가 |
npm install --global 패키지명 | yarn global add 패키지명 | 패키지를 전역 수준으로 추가 |
npm update --save | yarn upgrade | 프로젝트 패키지 업데이트 |
npm run 스크립트명 | yarn 스크립트명 | package.json의 스크립트 명령 실행 |
npm uninstall --save 패키지명 | yarn remove 패키지명 | 패키지 삭제 |
npm cache clean | yarn cache clean | 캐쉬 삭제 |
npm install --global nodemon
npm i (package.json에 있는 라이브러리 중 없는 라이브러리를 설치함)
tsconfig.json에 내가 설정한 명세에 맞게 typescriptcompile (tsc)을 하여, outDir 파일에 모아두고, prestart(빌드) => start 실행을 거친다.
그 외에 사항들은 tsconfig와 package.json에 있는 스크립트를
유심히 살피면 다 이해가 가능하다.
npm install express --save
#Dev Dependancy에서 @types/express를 설치합니다. (type script용 모듈들은 결국 최종적으로 app.js로 떨어지기 때문에, devDependancy에 설치합니다.
npm i @types/express -D
//app.ts예제 코드
import * as express from "express";
const app: express.Express = express();
const port: number = 8000;
app.get("/", (req, res) => {
res.send("Hello World!");
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
//위 코드를 컴파일하여 app.js로 최종적인 결과물을 실행 할 겁니다.
이렇게 express + tyepscript까지 설치하고, 그 컴파일의 흐름까지 간략하게 설명을 남겨놓았습니다.