profile image

L o a d i n g . . .

npm run dev로 웹팩을 실행하는데 에러가 뭔가 왕창 났다.

 

가장 상단 에러는 

resolve 'react-dom/client' in '경로'  Parsed request is a module였다.

 

client.jsx에서도

Cannot find module 'react-dom/client' or its corresponding type declarations.ts(2307)라는 오류가 뿜뿜하고있었다.
import * as React from "react"
import { createRoot } from "react-dom/client"
import Games from "./Games"


const container = document.getElementById("root")
const root = createRoot(container!) 
root.render(<Games />)

찾아보니 리액트 버전 v18에서 v17로 바꾼 후 아래부분을 수정하지 않아서 생겼던 오류였다.

 

 

현재쓰는 버전이 17이기때문에 아래처럼 client.jsx (자주쓰는건 App.jsx)를 바꿔주었다.

import * as React from "react"
import ReactDOM from "react-dom"

import Games from "./Games"

ReactDOM.render(<Games />, document.getElementById("root"))

 

 

실행이 잘 된다.

반응형
복사했습니다!