Cannot find module 'react' 에러

Luvlace·2021년 3월 5일

ERROR

목록 보기
2/2

1.에러 발생 상황
next를 실행하려는데 다음과 같은 에러가 발생했다.

The module 'react' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install react'
The module 'react-dom' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install react-dom'
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'react'
Require stack:
- C:\dev\react-nodebird\prepare\front\node_modules\next\dist\bin\next
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (C:\dev\react-nodebird\prepare\front\node_modules\next\dist\bin\next:26:13)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\dev\\react-nodebird\\prepare\\front\\node_modules\\next\\dist\\bin\\next'
  ]
}

2.해결방법
에러내용 그대로 react와 react-dom이 존재하지 않는다는게 문제다

npm i react react-dom

직접 react와 react-dom을 설치해 에러를 해결했다

0개의 댓글