以下の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}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。