[Bug]: Plugin Development documentation for Content-Types causes server issues
Link to the documentation page or resource
https://docs.strapi.io/developer-docs/latest/developer-resources/plugin-api-reference/server.html#content-types
Describe the bug
Following along with the examples and instructions used to create Content-Types during plugin development causes the following error message:
[2021-12-02 16:12:57.335] error: Cannot set properties of undefined (setting 'plugin')
TypeError: Cannot set properties of undefined (setting 'plugin')
at formatContentTypes (PATH\TO\PROJECT\strapi-4-test\node_modules\@strapi\strapi\lib\core\loaders\plugins\index.js:62:23)
at Object.loadPlugins (PATH\TO\PROJECT\strapi-4-test\node_modules\@strapi\strapi\lib\core\loaders\plugins\index.js:116:3)
at async Strapi.loadPlugins (PATH\TO\PROJECT\strapi-4-test\node_modules\@strapi\strapi\lib\Strapi.js:279:5)
at async Promise.all (index 1)
at async Strapi.register (PATH\TO\PROJECT\strapi-4-test\node_modules\@strapi\strapi\lib\Strapi.js:311:5)
at async Strapi.load (PATH\TO\PROJECT\strapi-4-test\node_modules\@strapi\strapi\lib\Strapi.js:409:5)
at async Strapi.start (PATH\TO\PROJECT\strapi-4-test\node_modules\@strapi\strapi\lib\Strapi.js:161:9)
error Command failed with exit code 1.
Additional context
I am testing the new plugin development procedure introduced in Strapi 4. I am using the documentation examples and steps as guidlines to get a basic contact form plugin running.
I am re-writing the plugin which was working in Strapi v3.6.8.
The following code snippets are adapted from the documentation:
- pluginName/strapi-server.js:
"use strict";
const bootstrap = require("./server/bootstrap");
const services = require("./server/services");
const routes = require("./server/routes");
const controllers = require("./server/controllers");
const config = require("./server/config");
const contentTypes = require("./content-types");
module.exports = () => {
return {
bootstrap,
config,
routes,
controllers,
services,
contentTypes
};
};
- pluginName/content-types/index.js:
const message = require("./message");
module.exports = {
message : message // should re-use the singularName of the content-type
};
- pluginName/content-types/message.js:
module.exports = {
info : {
tableName : "content-type",
singularName : "message", // kebab-case mandatory
pluralName : "messages", // kebab-case mandatory
displayName : "Messages",
description : "A regular content type",
kind : "collectionType"
},
options : {
draftAndPublish : true
},
pluginOptions : {
"content-manager" : {
visible : true
},
"content-type-builder" : {
visible : true
}
},
attributes : {
name : {
type : "string",
required : true
},
message : {
type : "text",
required : true
},
email : {
type : "email",
required : true
}
}
};
Suggested improvements or fixes
Review plugin development documentation and ensure that examples offer sufficient guidlines to get a basic plugin running. Future Strapi 4 tutorials would perhaps alleviate these issues.
Related issue(s)/PR(s)
No response
Hello @CaeCur, I am sorry this issue went so long without a response. I think we have made multiple updates to the plugin documentation in that time. Do you find the current documentation sufficient? If not, please let me know what is not clear and I can try to propose some additions or fixes. Thanks for contributing to the Strapi documentation.
Hello. I'm sorry that you were having troubles and that this issue didn't get more attention sooner. I'm cleaning up old documentation issues and I will close this issue now. Feel free to open a new issue if you're still having trouble with the documentation for Strapi v4.11+