React module not found after upgrading strapi to 4.20.5

node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module 'react'
Require stack:
- /Users/-/js-projects/strapi/app/node_modules/@strapi/admin/dist/_chunks/index-sNH2VWbC.js
- /Users/-/js-projects/strapi/app/node_modules/@strapi/admin/dist/cli.js
- /Users/-/js-projects/strapi/app/node_modules/@strapi/admin/index.js
- /Users/-/js-projects/strapi/app/node_modules/@strapi/strapi/dist/commands/actions/watch-admin/action.js
- /Users/-/js-projects/strapi/app/node_modules/@strapi/strapi/dist/commands/actions/watch-admin/command.js
- /Users/-/js-projects/strapi/app/node_modules/@strapi/strapi/dist/commands/index.js
- /Users/-/js-projects/strapi/app/node_modules/@strapi/strapi/dist/cli.js
- /Users/-/js-projects/strapi/app/node_modules/@strapi/strapi/bin/strapi.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/Users/keegankwirant/js-projects/strapi/app/node_modules/@strapi/admin/dist/_chunks/index-sNH2VWbC.js:15:15)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19) {
  code: 'MODULE_NOT_FOUND',

I’ve tried removing the lock file + deleting node_modules, I then run yarn build where this error occurs

This topic has been created from a Discord post (1219432771894775879) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

3 Likes