byeonghun_app_2021[1]

김병훈·2021년 9월 11일
0

byeonghun_app_2021

목록 보기
1/2

origin 지우기

  • PART 1 실습이 끝나고 commit을 하고 push를 했는데 업로드가 되었다고 떴는데도, 깃헙에 업로딩이 되지않아서 갈아 엎을 뻔했는데, 그냥 레포만 지우고 하나 다시 만들어서 origin을 추가하려고 했는데, 이미 있다고 해서 당황했다..하지만?
    git remote remove origin 으로 origin 지울 수 있었다. 그래서 지우고 다시 새로운 레포를 넣어줬다.
  • 근데 staged area에 add된게 없어서 그냥 client , server 폴더 바깥에 md파일을 하나 만들어서 커밋을 하니까 전부 다 업로드가 되었다.

Client 만들기

make a folder
$npx create-react-app client
$mkdir server

in client, 
$git init
$git remote add origin GITREPO
(make a .md file)
$git add .
$git push origin master
  • $npx create-react-app client 해준 폴더 안에서 수정..

Server 만들기

in client cd ..
cd server
make a index.js file
$npm init
$npm install express body-parser mysql
$npm install nodemon
in "scripts": {} of package.json (server)
- add "start": "node index.js",
- "devStart": "nodemon index.js",

  • 위에서 "devStart": "nodemon index.js", 을 추가해준걸 npm run devStart으로 nodemon을 사용하면 내가 코드를 수정할 때마다 노드몬이 바로 실행이 되어서 서버에 바로 적용이된다 ( 하지만 페이지는 새로고침해야 함)
  • in index.js
const express = require('express');
const app = express();

app.listen(3000, () => {
  console.log('running on port 3000');
});
  • 그리고 node index.js 하면
  • 하지만 크롬에서 http://localhost:3000/ 로 들어가면 아직 get 요청을 해준 것이 없어서 아래 처럼 나온다.
  • 아래 코드를 다시 추가해주면 사진처럼 된다.
app.get('/', (req, res) => {
  res.send('hello world');
});

profile
블록체인 개발자의 꿈을 위하여

1개의 댓글

Good essay for geometry dash online

답글 달기