teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

コードの追記

2021/06/04 11:01

投稿

kosuke519
kosuke519

スコア5

title CHANGED
File without changes
body CHANGED
@@ -33,8 +33,78 @@
33
33
  }
34
34
 
35
35
  }
36
+ ```
37
+ serverフォルダのpackage.jsonです
38
+ ```ここに言語を入力
39
+ {
40
+ "name": "server",
41
+ "version": "1.0.0",
42
+ "description": "",
43
+ "main": "index.js",
44
+ "scripts": {
45
+ "start": "node server.js",
46
+ "devStart": "nodemon server.js",
47
+ "test": "echo \"Error: no test specified\" && exit 1"
48
+ },
49
+ "author": "",
50
+ "license": "ISC",
51
+ "dependencies": {
52
+ "body-parser": "^1.19.0",
53
+ "cors": "^2.8.5",
54
+ "express": "^4.17.1",
55
+ "mysql": "^2.18.1",
56
+ "nodemon": "^2.0.7"
57
+ }
58
+ }
36
59
 
37
60
  ```
61
+ creatReactAppのpackage.jsonです
62
+ ```ここに言語を入力
63
+ {
64
+ "name": "****",
65
+ "version": "0.1.0",
66
+ "private": true,
67
+ "proxy": "http://localhost:3001",
68
+ "dependencies": {
69
+ "@testing-library/jest-dom": "^5.12.0",
70
+ "@testing-library/react": "^11.2.6",
71
+ "@testing-library/user-event": "^12.8.3",
72
+ "axios": "^0.21.1",
73
+ "react": "^17.0.2",
74
+ "react-dom": "^17.0.2",
75
+ "react-scripts": "4.0.3",
76
+ "web-vitals": "^1.1.1"
77
+ },
78
+ "scripts": {
79
+ "start": "react-scripts start",
80
+ "build": "react-scripts build",
81
+ "test": "react-scripts test",
82
+ "eject": "react-scripts eject"
83
+
84
+
85
+
86
+ },
87
+ "eslintConfig": {
88
+ "extends": [
89
+ "react-app",
90
+ "react-app/jest"
91
+ ]
92
+ },
93
+ "browserslist": {
94
+ "production": [
95
+ ">0.2%",
96
+ "not dead",
97
+ "not op_mini all"
98
+ ],
99
+ "development": [
100
+ "last 1 chrome version",
101
+ "last 1 firefox version",
102
+ "last 1 safari version"
103
+ ]
104
+ }
105
+
106
+
107
+ ```
38
108
  Heroku上にcreatReactAppをビルドするにはどうすればいいでしょう?
39
109
  上記の参考サイトにある対応としてcreatReactAppの.gitフォルダを削除し、add,commitしましたがビルドされませんでした。
40
110
  ご教示いただけると幸いです。

3

コードの追記

2021/06/04 11:01

投稿

kosuke519
kosuke519

スコア5

title CHANGED
File without changes
body CHANGED
@@ -9,6 +9,32 @@
9
9
  res.sendFile(path.join(__dirname, "../client/build/index.html"));
10
10
  });
11
11
  ```
12
+
13
+ ディレクトリのpackage.jsonです
14
+ ```{
15
+ "name": "*****",
16
+ "version": "1.0.0",
17
+ "description": "",
18
+ "main": "index.js",
19
+ "scripts": {
20
+ "test": "echo \"Error: no test specified\" && exit 1",
21
+ "start": "node server/server.js",
22
+ "heroku-postbuild": "cd client && npm install && npm run build"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/*****/*****.git"
27
+ },
28
+ "keywords": [],
29
+ "author": "",
30
+ "license": "ISC",
31
+ "bugs": {
32
+ "url": "https://github.com/*****/*****/issues"
33
+ }
34
+
35
+ }
36
+
37
+ ```
12
38
  Heroku上にcreatReactAppをビルドするにはどうすればいいでしょう?
13
39
  上記の参考サイトにある対応としてcreatReactAppの.gitフォルダを削除し、add,commitしましたがビルドされませんでした。
14
40
  ご教示いただけると幸いです。

2

誤字の修正

2021/06/04 06:45

投稿

kosuke519
kosuke519

スコア5

title CHANGED
File without changes
body CHANGED
@@ -10,5 +10,5 @@
10
10
  });
11
11
  ```
12
12
  Heroku上にcreatReactAppをビルドするにはどうすればいいでしょう?
13
- 上記の参考サイトにある対応としてcreatReactAppの.gitフォルダを削除し、add,commitしましたが
13
+ 上記の参考サイトにある対応としてcreatReactAppの.gitフォルダを削除し、add,commitしましたがビルドされませんでした。
14
14
  ご教示いただけると幸いです。

1

参考にしたサイトのURL追加、その他質問文の修正

2021/06/03 11:54

投稿

kosuke519
kosuke519

スコア5

title CHANGED
@@ -1,1 +1,1 @@
1
- Reactのアプリをherokuにデプロイしたのですが、ント(client)フォダがビルドされず空です。
1
+ Reactのアプリをherokuにデプロイしたのですが、ローカビルドしたファイルが空です。
body CHANGED
@@ -1,17 +1,14 @@
1
- herokuにデプしたアプリのサイトに行くとnot foundと表示され、ログを確認すると以下の文章を見つけまし
1
+ ーカルでビルドしたcreatReactAppのフォルダがHeroku上でビルドされず空になっており、アプリを開くとNotFoundと表示されてしまします
2
- ```ここに言語を入力
3
- Error: ENOENT: no such file or directory, stat ‘/app/client/build/index.html
4
- ```
5
2
 
6
3
 
7
- git run bashを使いフロント(client)フォルダの中身見ると空でした。
4
+ [こちらサイト参考にデプロイました。](http://reffect.co.jp/react/front-react-back-node)
8
- 再度フロントの.gitフォルダ削除してプッシュするとこまでやり直しましが空ままです。
5
+ こちらがサーバーからReact表示するたパスです。
9
-
10
- 以下のスクリプトをルートディレクトリのpackage.jsonに書いておりますがこちらの記述が間違いなのでしょうか?。
11
6
  ```
7
+ app.use(express.static(path.join(__dirname, "../client/build")));
8
+ app.get("*", (req, res) => {
12
- "heroku-postbuild": "cd client && npm install && npm run build"
9
+ res.sendFile(path.join(__dirname, "../client/build/index.html"));
10
+ });
13
11
  ```
14
-
15
-
16
- フロント(client)フォルダをビルドするにはどうすればいいでしょう
12
+ Heroku上にcreatReactAppをビルドするにはどうすればいいでしょう?
13
+ 上記の参考サイトにある対応としてcreatReactAppの.gitフォルダを削除し、add,commitしましたが
17
14
  ご教示いただけると幸いです。