inflearn logo
강의

講義

知識共有

作成しながら学ぶフロントエンドDO ITコーディング(Next.js、Typescript)

firebase adminコードの追加

@types/react를 인식하지 못하는 에러

2828

fe

投稿した質問数 25

0

강사님 안녕하세요. 이 전 질문에 대한 답변으로 get 요청에 대한 문제는 해결했습니다 감사합니다^^

그런데 이후 다음과 같은 문제가 발생하였습니다.

 


package-lock.json 삭제하고, node_modules 폴더도 삭제한 뒤 yarn 으로 패키지 재설치하였고,

yarn dev, yarn build 등 명령어를 입력하면 다음과 같은 에러 메시지가 출력되면서 localhost:3000에 진입할 수 없습니다.

@types/react를 최신버전으로 다시 설치해봤고, 강의에서 사용중인 버전인 ^17.0.37으로도 다시 설치해봤고, vscode 종료 후 재실행하여도 동일한 에러메시지가 계속 출력됩니다.

해당 에러 메시지는 npm run dev 명령어를 입력해도 @types/react를 설치하라는 에러가 발생합니다.

자체 해결

https://stackoverflow.com/questions/71843307/next-js-is-not-recognizing-types-react

위 스택오버플로우 답변을 보고 @types/react 버전을 18.0.1 버전으로 변경했습니다. 결과적으로 문제는 해결되었습니다.

그러나 의문점은, 강의에서 사용하는 버전은 ^17.0.37인데 저의 경우만 18.0.1버전으로 변경해야 작동하는 것인지?

아니면 다른 분들도 작동하지 않으시는지? 저만 그런것이라면 원인이 무엇일지 궁금합니다.

 

ready - started server on 0.0.0.0:3000, url: http://localhost:3000

info  - Loaded env from /Users/hanair/dev/blahx2/.env

It looks like you're trying to use TypeScript but do not have the required package(s) installed.

Please install @types/react by running:

        yarn add --dev @types/react

If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).

error Command failed with exit code 1.

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

 

package.json 파일은 다음과 같습니다.

{

  "name": "blahx2",

  "private": true,

  "scripts": {

    "dev": "next dev",

    "build": "next build",

    "start": "next start",

    "lint": "next lint"

  },

  "dependencies": {

    "@chakra-ui/react": "1.8",

    "@emotion/react": "^11.10.6",

    "@emotion/styled": "^11.10.6",

    "firebase": "^9.20.0",

    "firebase-admin": "^11.7.0",

    "framer-motion": "^6.5.1",

    "next": "12.0.7",

    "react": "17.0.2",

    "react-dom": "17.0.2",

    "styled-components": "^5.3.3"

  },

  "devDependencies": {

    "@types/node": "^16.11.13",

    "@types/react": "^17.0.58",

    "@types/styled-components": "^5.1.18",

    "@typescript-eslint/eslint-plugin": "^5.8.0",

    "@typescript-eslint/parser": "^5.8.0",

    "babel-eslint": "^10.1.0",

    "babel-plugin-styled-components": "^2.0.2",

    "eslint": "8.4.1",

    "eslint-config-airbnb": "^19.0.2",

    "eslint-config-airbnb-base": "^15.0.0",

    "eslint-config-airbnb-typescript": "^16.1.0",

    "eslint-config-next": "12.0.7",

    "eslint-config-prettier": "^8.3.0",

    "eslint-plugin-babel": "^5.3.1",

    "eslint-plugin-import": "^2.25.3",

    "eslint-plugin-jsx-a11y": "^6.5.1",

    "eslint-plugin-prettier": "^4.0.0",

    "eslint-plugin-react": "^7.27.1",

    "eslint-plugin-react-hooks": "^4.3.0",

    "prettier": "^2.5.1",

    "typescript": "^4.5.4"

  }

}

next.js

回答 3

1

brbr

저도 따라하다가,

react version 18로 설치했는데 잘 되어서 그렇게 사용하고 있습니다 (v17로는 최신버전이나 이런 저런 버전조합을 해봐도 해결책을 못 찾았습니다)

 

 "dependencies": { "@chakra-ui/react": "^2.8.2", "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", "firebase-admin": "^12.0.0", "framer-motion": "^11.0.5", "next": "^12.0.7", "react": "^18.2.0", "react-dom": "^18.2.0", "styled-components": "^5.3.3" }, "devDependencies": { "@types/node": "^16.11.13", "@types/react": "^18.2.55", "@types/styled-components": "^5.1.18", "@typescript-eslint/eslint-plugin": "^5.8.0", "@typescript-eslint/parser": "^5.8.0", "babel-eslint": "^10.1.0", "babel-plugin-styled-components": "^2.0.2", "eslint": "^8.52.0",

0

hibnos

"react": "17.0.2" 와 "@types/react":"17.0.71" 두개의 버젼이 호환이 안되어 나타나는 에러

"@types/react": "17.0.19" 버젼으로 재설치 해주면 정상적으로 작동 한다.

npm install --save @types/react@17.0.19

0

totuworld

안녕하세요 fe님.

https://github.com/totuworld/blahx2-tutorial

위 레포 기준으로 yarn.lock 이라 package.json 맞추신 뒤 패키지 다시 설치해보시겠어요?

post하는 경우에 uid 설정

0

138

1

vscode bgColor 바로 표시되기 설정방법 및 chakra-ui img src 설정관련

0

508

2

클래스 방식말고 (2)

0

327

1

클래스 방식말고

0

311

1

배포 후 오류

0

1150

3

const resp = await fetch(`/api/messages.list?uid=${uid}`)가 404에러가 뜹니다

0

438

1

localhost:3000/api/user.info/totuworld 404 에러가 뜹니다.

0

436

3

사용자를 찾을 수 없다.

0

378

1

2. 사용자 API 만들기 => 강의는 짧지만 백엔드 api 만드는 기본 내용 다 들어가 있음 주의하세요!!

0

379

1

toast 처리부터 오류발생

0

599

3

FirebaseError: Firebase: Error (auth/invalid-api-key).

0

1830

3

Vercel 배포 후 thumbnail api 에러 발생합니다.

0

705

1

[~~].toStr에 대해

0

248

1

firebase admin 환경 초기화 하는 부분 질문입니다.

0

405

1

/api/[screenName].ts API에 대해 문의드립니다.

0

339

1

구글 가입 버튼 오류: redirect_uri_mismatch

0

535

1

mac m1 node 14버전 설치 에러

0

642

1

전체 예제 소스좀 올려주세요

0

445

1

R_CONNECTION_TIMED_OUT 오류

0

624

1

로그인 버튼 클릭시 auth/auth-domain-config-required 에러 발생

0

707

1

thunder client로 get 요청시 무한로딩

0

1154

1

firebase auth 인증 질문

0

1207

1

router 관련 질문입니다.

0

381

1

자동 줄바꿈

0

379

1