strapi-plugin-menus icon indicating copy to clipboard operation
strapi-plugin-menus copied to clipboard

TypeError: Cannot read properties of undefined (reading 'schema')

Open sergheiCovali opened this issue 1 year ago • 1 comments

I've added strapi-server.js in src/extensions/menus/

// ./src/extensions/menus/strapi-server.js` "use strict";

module.exports = (plugin) => { // Get current MenuItem attributes. const defaultAttrs = plugin.contentTypes["'menu-item'"].schema.attributes;

// Define custom attributes for MenuItem the same way they would be defined // on any other schema. const customAttrs = { short_description: { type: "string", }, };

// Extend the MenuItem content type with custom attributes. plugin.contentTypes["'menu-item'"].schema.attributes = { ...defaultAttrs, ...customAttrs, };

return plugin; };

after this when I run -> npm run develop strapi I get this error

TypeError: Cannot read properties of undefined (reading 'schema') ││ at module.exports (/Users..../../../../src ││ /extensions/menus/strapi-server.js:6:58) ││ at applyUserExtension

sergheiCovali avatar Dec 19 '23 10:12 sergheiCovali

Hi @sergheiCovali This extension portion of your code looks okay. Can you provide more details from your package.json and config/plugins.js? The error suggests the MenuItem content type isn't registered with Strapi but it should be.

mattmilburn avatar Jan 07 '24 16:01 mattmilburn