Migration of Strapi 4 plugins to Strapi 5

System Information
  • 5.9.0:
  • Mac OS X 15.1.1 (24B91):
  • MySql 8.0:
  • v20.18.2:
  • 10.8.2:
  • 4.6.0:

Hello Community,

After hours of trying I gave up and hope this forum can help. I want to upgrade my strapi version 4 to 5. Therefore I had no problems to update to the last 4.25.20. Also my plugins are working. The catastrophy starts when I upgrade to 5.9.0. The process was successfully after many many hours. But now I stuck with the plugin-developing. Following the docs I create a new plugin with name sqljob. Now I want to copy my code from strapi version 4 directory to the new created directory but it seems that the yarn build command does not build my plugin.

Step by Step →
What I did was:

  1. I updated to the last strapi 4 version.
  2. Then I upgraded to version 5.
  3. I moved my old plugin under src/plugins into an another directory outside of strapi dir.
  4. Then I upgraded yarn, because the command yarn dlx @strapi/sdk-plugin init my-strapi-plugin did not succeeded. After hours of upgrading node, npm and yarn (see versions above) now it runs
  5. But the linking with ** ```
    yarn dlx yalc add --link my-strapi-plugin && yarn install** fails with error: Could not find package sqljob in store (/Users/sven/.yalc/packages/sqljob), skipping. (btw yalc I installed previosly also)
  6. yarn build seems to work but if I add some wrong codes or senseless words in my source files under src/plugin, yarn build does not complain, so I think, my plugin is not compiled and will not compiled. Why??? All errors and mistakes and … only after the upgrade of my strapi to version 5.

The documents are not very helpfully. Who has experiences with the plugin development under version 5 and could be so kind to give me a bit more details, helping me with migration of my version 4-plugins for strapi 5.

Thank you very much!
Sven

Hello Community,

First of all, I deleted all yarn references, because yarn in the new version is really a mess (for me). I installed all clean. Node and NPM.
After the step 4 from above, I found out, that in Version 5 of Strapi, every plugin has to be compiled separatеly. I do not know, why yarn dlx yalc add --link my-strapi-plugin && yarn install did and do not work. The errormessage is absolutly nonsense (in my eyes).
But now, with npm only every things works. The problem with the compiling process can be solved with a modification in package.json. Here we go:

"scripts": {
    "develop": "npm-run-all build-plugins --parallel watch-plugins strapi-develop",
    "strapi-develop": "strapi develop",
    "build-plugins": "npm run build-sqljob",
    "watch-plugins": "nodemon --watch src/plugins -e js,jsx,json --ignore src/plugins/**/dist --ignore src/plugins/**/build --exec \"npm run build-plugins\"",
    "build-sqljob": "cd src/plugins/sqljob && npm run build",
    "start": "strapi start",
    "build": "strapi build",
    "strapi": "strapi"
  },

Important! You have to install npm install npm-run-all --save-dev. For now, every time, when source code in plugins is changing, the plugin will be compiled again and strapi starts with npm run develop automaticly.

Maybe somebody has an another idea, your welcome. I am interested in using the link option of yalc, but I do not know, why I get this strange error message. The process is now working and I am interested in suggestions to do it better.

regards,
Sven