티스토리 뷰
1번 VS 켜고 폴더만든다.
2번 index.js 만든다.
3번 윈도우 기준 cmd 켠다(powershell안됨). index.js 경로로 간다.
4번 cmd에 yarn install 입력
yarn install // node modules
5번 yarn init 입력, question들은 기본값으로 만든다(엔터 눌러라)
yarn init // package json
6번 package.json 들어가서 사진처럼 type, script 입력
7번 express 사이트 들어가서 (사이트 : express - npm (npmjs.com)) 인덱스에 사진처럼 넣어주자
※ 이렇게 바꾸면 아래 과정을 안해도 된다. const express = require('express') -> import express from 'express'
잘 되는지 cmd에 yarn dev 입력
에러가 떴다 해결 링크 : How to fix the error `require is not defined` in Node.js (coderslang.com)
package 안에서 "type": "module"을 찾아 "type": "commonjs"로 바꾸자
성공
postman에서(postman 설치 : Download Postman | Get Started for Free ) 확인하자
파란색 send 눌러서 Hello World 보이면 성공
'개발자 > node js rest-api' 카테고리의 다른 글
객체의 키를 큰따옴표("" 혹은 '')로 감싸는 이유 (0) | 2022.01.18 |
---|---|
nodemon 깔기 (0) | 2022.01.15 |
express 설치하기 (0) | 2022.01.15 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 도커
- 공부법
- Spread
- Playground
- Rest
- yarn
- Callback
- js
- arrow
- nodemon
- postman
- 코드캠프
- 에러
- 백틱
- NPM
- 코딩습관
- elasticsearch
- 명령어
- Console
- 콜백
- typeorm
- function
- 프로그래머스
- 호이스팅
- arrowfunction
- error
- axios
- 독커
- GraphQL
- docker
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
글 보관함