質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

Q&A

解決済

1回答

658閲覧

Heroku pushエラーになってしまう デプロイできない

TomoEno

総合スコア53

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

0グッド

0クリップ

投稿2022/05/20 12:06

以下のURL通りにフロントはReact、バックはnodeで制作したものをHerokuにデプロイしようとしています。
https://reffect.co.jp/react/front-react-back-node
何度かエラーになりつつもエラー内容を調べながら、行いましたが、
Herokuでコンパイルが出来ず、pushされないという以下の文章が出ます。

Failed to compile.

TS7016: Could not find a declaration file for module 'styled-components'. '/tmp/build_e17f7a21/frontend/node_modules/styled-components/dist/styled-components.cjs.js' implicitly has an 'any' type. Try `npm i --save-dev @types/styled-components` if it exists or add a new declaration (.d.ts) file containing `declare module 'styled-components';` > 1 | import styled, { StyledComponent } from "styled-components" | ^^^^^^^^^^^^^^^^^^^ 2 | import { Top } from "./components/Top"; 3 | import { Bottom } from "./components/Bottom"; 4 |

-----> Build failed

We're sorry this build is failing! You can troubleshoot common issues here: https://devcenter.heroku.com/articles/troubleshooting-node-deploys If you're stuck, please submit a ticket so we can help: https://help.heroku.com/ Love, Heroku

! Push rejected, failed to compile Node.js app.
! Push failed

VS codeではエラーが出ていませんが、Reactで制作したファイル内で指示通りのコマンドnpm i --save-dev @types/styled-componentsを行った後にReactをbuildして、nodeに紐づけたりなどしました。

しかし、一向に同じエラーが出ます。

解決方法をご教授していただければと存じます。

nodeのpackage.json

1{ 2 "name": "catbot", 3 "version": "1.0.0", 4 "engines": { 5 "node": "v16.14.2" 6 }, 7 "description": "", 8 "main": "index.js", 9 "scripts": { 10 "test": "echo \"Error: no test specified\" && exit 1", 11 "start": "node backend/index.js", 12 "heroku-postbuild": "cd frontend && npm install && npm run build" 13 }, 14 "keywords": [], 15 "author": "", 16 "license": "ISC", 17 "dependencies": { 18 "body-parser": "^1.20.0", 19 "dotenv": "^16.0.1", 20 "express": "^4.18.1", 21 "nodemailer": "^6.7.5" 22 } 23}

Reactのpackage.json

1{ 2 "name": "frontend", 3 "version": "0.1.0", 4 "private": true, 5 "proxy": "http://localhost:3001", 6 "dependencies": { 7 "@testing-library/jest-dom": "^5.16.4", 8 "@testing-library/react": "^13.1.1", 9 "@testing-library/user-event": "^13.5.0", 10 "@types/jest": "^27.4.1", 11 "@types/node": "^16.11.29", 12 "@types/react": "^18.0.7", 13 "@types/react-dom": "^18.0.0", 14 "axios": "^0.27.2", 15 "react": "^18.2.0-next-d20c3af9d-20220506", 16 "react-dom": "^18.2.0-next-d20c3af9d-20220506", 17 "react-scripts": "5.0.1", 18 "styled-components": "^5.3.5", 19 "typescript": "^4.6.3", 20 "typewriter-effect": "^2.18.2", 21 "web-vitals": "^2.1.4" 22 }, 23 "scripts": { 24 "start": "react-scripts start", 25 "build": "react-scripts build", 26 "test": "react-scripts test", 27 "eject": "react-scripts eject" 28 }, 29 "eslintConfig": { 30 "extends": [ 31 "react-app", 32 "react-app/jest" 33 ] 34 }, 35 "browserslist": { 36 "production": [ 37 ">0.2%", 38 "not dead", 39 "not op_mini all" 40 ], 41 "development": [ 42 "last 1 chrome version", 43 "last 1 firefox version", 44 "last 1 safari version" 45 ] 46 }, 47 "devDependencies": { 48 "@types/react-typist": "^2.0.3", 49 "@types/styled-components": "^5.1.25" 50 }, 51 "peerDependencies": { 52 "webpack": "^5.72.1" 53 } 54}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

試しにnodeのファイル側で"npm i --save-dev @types/styled-components"を行い、
nodeのpackage.jsonが以下のようになりましたら、herokuへpushとデプロイができました。

nodeのpackage.json

1"devDependencies": { 2 "@types/styled-components": "^5.1.25" 3 }

投稿2022/05/20 12:35

TomoEno

総合スコア53

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問