reactjs 가 windows 환경 에서 npm run build 를 사용 한 후 웹 페이지 를 열 어 빈 해결 방안 으로 표시 합 니 다.

처음에 react 를 배 웠 을 때 홈 페이지 의 조작 에 따라:
npx create-react-app my-app
cd my-app
npm start

이 초기 프로젝트 를 구축 한 후에 프로젝트 가 정상적으로 접근 할 수 있 음 을 발견 합 니 다!
그 다음 에 바로 출시 를 하 겠 습 니 다.
npx run build

그런데 index. html 인 터 페 이 스 를 직접 여 는 게 공백 이 었 어 요.
이 럴 때 저희 가 build 의 정 보 를 봅 니 다.
> [email protected] build D:\Program Filesodejs\my-app> react-scripts buildCreating an optimized production build...Compiled successfully.File sizes after gzip:  36.94 KB  build\static\js\main.a0b7d8d3.js  299 B     build\static\css\main.c17080f1.cssThe project was built assuming it is hosted at the server root.You can control this with the homepage field in your package.json.For example, add this to build it for GitHub Pages:  "homepage" : "http://myname.github.io/myapp",The build folder is ready to be deployed.You may serve it with a static server:  npm install -g serve  serve -s buildFind out more about deployment here:
  http://bit.ly/2vY88Kr
빨간색 글꼴 부분 보기:
구 글 번역:
이 항목 은 서버 루트 디 렉 터 리 에 있다 고 가정 합 니 다.package. json 의 홈 페이지 필드 를 사용 하여 제어 할 수 있 습 니 다.예 를 들 어 GitHub 페이지 에 추가 해서 구축 합 니 다.   “homepage”:“http://myname.github.io/myapp”,
즉, 기본적으로 웹 서버 이기 때문에 생 성 된 index. html 파일 의 경 로 는 다음 과 같 습 니 다.


< p > < span style = "background - color: rgb (255, 255, 255);" > 그래서 웹 페이지 를 열 때 개발 자 모드 (F12) 를 열 면 이 파일 을 찾 을 수 없습니다. 경로 에 문제 가 있 기 때 문 입 니 다! < /span>


< p > < span style = "background - color: rgb (255, 255, 255);" > 정확 한 경 로 는 < / span > < / p >



< p > < span style = "background - color: rgb (255, 255, 255);" > 사실 이 문 제 를 어떻게 해결 하 는 지 에 대해 build 할 때 이미 힌트 를 주 었 습 니 다. 바로 위 에 표 시 된 빨간색 영어 입 니 다. < / span > < / p >

The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:


  "homepage" : "http://myname.github.io/myapp",


< p > < span style = "background - color: rgb (255, 255, 255);" > < span style = "color: \ # 000000;" > 는 package. json 파일 의 홈 페이지 속성 을 수정 하여 수정 할 수 있 음 을 알려 줍 니 다. 프로젝트 루트 디 렉 터 리 에 있 는 package. json 을 열 어 보 니 홈 페이지 라 는 속성 이 없 음 을 발 견 했 습 니 다. 이 럴 때 는 수 동 으로 추가 해 야 합 니 다. 다음 과 같 습 니 다. < / span > < / span >

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "homepage":"./",
  "dependencies": {
    "react": "^16.4.1",
    "react-dom": "^16.4.1",
    "react-scripts": "1.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }


}


< p > < span style = "color: \ # 000000; background - color: rgb (255, 255, 255);" > 이때 우 리 는 npm run build 에서 index. html 의 경로 가 변 한 것 을 발견 하고 index. html 를 열 면 정상적으로 표 시 됩 니 다! < / span > < / p >
< p > < span style = "color: \ # 000000; background - color: rgb (255, 255, 255);" > (소 백 로그) < / span > < / p >



Gencarqq Situs Pkv games Terpercaya
DB 연습하기 - 06

좋은 웹페이지 즐겨찾기