1. vscode에서 git bash 상에서 작업을 하도록 하겠다. git 다운로드 및 설치는 https://planguage.tistory.com/7 를 참고하도록 하라.
2. nodejs 설치 https://nodejs.org/ko
Node.js
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
nodejs.org
안정화 버전을 다운로드하세요.
$ npm -v
로 설치 확인을 하도록 한다.
$ npm install -g yarn
$ yarn global add create-react-app
이제 만들고 싶은 폴더로 이동을 한다.
$ mkdir server
$ cd server
$ yarn create react-app my-app
$ cd my-app
$ npm start
ctrl+c 를 누르면 서버에서 빠져나올 수 있다.
$ yarn build
다음은 web.js라는 파일 안에 다음 내용을 넣는다.
const express = require("express");
const app = express();
const path = require("path");
const PORT = 8001;
app.use(express.static(path.join(__dirname, "build")));
app.get("/", function (req, res) {
res.sendFile(__dirname + "/build/index.html");
});
app.get("/faq", function (req, res) {
res.sendFile(__dirname + "/build/index.html");
});
app.get("/curriculum", function (req, res) {
res.sendFile(__dirname + "/build/index.html");
});
app.listen(PORT, () => {
console.log(`server started on PORT ${PORT}`);
});
npm i
npm install express
다음은 package.json 파일로 간다.
그다음. gitignore파일 안에
# /build를 해 주도록 한다.
마지막으로. git 이 있는 위치에서 다음을 한다.
$ git init
$ git add .
$ git commit -m first
$ git remote add cafe24 복사한 저장소
$ git branch -M master
$ git push cafe24 master 오류가 나면
$ git push -f cafe24 master
LF will be replaced by CRLF the next time Git touches it
이런 에러 메시지가 나온다면 윈도라면
git config --global core.autocrlf true
linux, mac이라면
git config --global core.autocrlf input
복사한 저장소는 밑에 있는 저장소에 있는 내용 중에 git을 빼고 넣는다.
마지막으로
앱 중지 후 실행을 하면 완성이 된다.
이제 도메인에 접속을 해보자
약간의 시간의 필요하니 조금 기다리도록.
다른 해결이 필요한 부분은 댓글 남겨주세요
ssh-keygen (0) | 2023.07.09 |
---|---|
nodejs 호스팅 windows (0) | 2023.07.09 |