Error: Cannot read properties of undefined (reading 'attributes') TypeError: Cannot read properties of undefined (reading 'attributes') Strapi 4

System Information
  • Strapi Version: 4.1.12
  • Operating System: windows 11
  • Database: PostgreSQL
  • Node Version: v16.14.0
  • NPM Version: 8.10.0
  • Yarn Version:

How do I fix the error? Please help me with anyone.

1 Like

Hi @Mursalin_Ahmed did you find a way to tackle it? I am also facing the same issue.

1 Like

@johnwick I did not find a way to tackle it. then I recreate the new project. then has all right done. Thank you

I’m having this same issue after migrating a v3 app and following the docs. Most everything is default from the factory methods. It just doesn’t like something about the setup because this happens before or after any data is added (from the data migration scripts… i.e., they don’t make any difference).

Any clues on where to look would be appreciated:

[2022-07-31 01:25:30.939] debug: ⛔️ Server wasn't able to start properly.
[2022-07-31 01:25:30.939] error: Cannot read properties of undefined (reading 'attributes')
TypeError: Cannot read properties of undefined (reading 'attributes')
    at Object.getNonVisibleAttributes (/Users/rian/github/devoe-strapi-4/node_modules/@strapi/utils/lib/content-types.js:69:11)
    at getNestedFields (/Users/rian/github/devoe-strapi-4/node_modules/@strapi/admin/server/services/content-type.js:30:51)
    at /Users/rian/github/devoe-strapi-4/node_modules/@strapi/admin/server/services/content-type.js:43:31
    at /Users/rian/github/devoe-strapi-4/node_modules/lodash/lodash.js:928:11
    at /Users/rian/github/devoe-strapi-4/node_modules/lodash/lodash.js:4967:15
    at baseForOwn (/Users/rian/github/devoe-strapi-4/node_modules/lodash/lodash.js:3032:24)
    at /Users/rian/github/devoe-strapi-4/node_modules/lodash/lodash.js:4936:18
    at baseReduce (/Users/rian/github/devoe-strapi-4/node_modules/lodash/lodash.js:925:5)
    at Function.reduce (/Users/rian/github/devoe-strapi-4/node_modules/lodash/lodash.js:9749:14)
    at getNestedFields (/Users/rian/github/devoe-strapi-4/node_modules/@strapi/admin/server/services/content-type.js:32:12)
1 Like


I suddenly encountered this error while working with Strapi 4 on my project. I couldn’t understand why. Then I re-created the Strapi-API file without getting any solution. After that, I did not face this problem again.

Thank you

For what it’s worth, I discovered that the root cause of this error was not migrating the components from where they lived in v3 to the new v4 location. I ran the codemods, but it seemed to do only a very partial job, which of course, means that you need to go through everything manually anyway to see what it missed. I’d recommend not using any of the available “migration scripts” and just hacking away at the thing manually if you really want to make sure you got everything.

1 Like

Hello. I encountered the same problem as you. Removing one component helped me