Strapi v4: Cannot read properties of undefined (reading 'routes')

System Information
  • Strapi Version: 4.4.1 to 4.4.3
  • Operating System: MacOS 12.6
  • Database: PostgreSQL
  • Node Version: 16.15.0, 16.13.2
  • NPM Version: 8.5.5, 8.1.2
  • Yarn Version: 1.22.19

Strapi server cannot start at all on my PC, but starts on others and on our hosting provider:

A colleague of mine created a project with npx create-strapi-app@latest.
The project ran well so we proceeded to add some Collections and Single types to the project.
We filled the database with test data and uploaded project to GitHub.
I then proceeded to download the project with the intention of writing a plugin but I could not even start it with yarn develop or npm run develop.

Error stacktrace :

Admin UI built successfully
[2022-10-07 10:44:18.983] debug: ⛔️ Server wasn't able to start properly.
[2022-10-07 10:44:18.984] error: Cannot read properties of undefined (reading 'routes')
TypeError: Cannot read properties of undefined (reading 'routes')
    at Object.addCreateLocalizationAction (/Users/dev/
    at /Users/dev/
    at Array.forEach (<anonymous>)
    at extendLocalizedContentTypes (/Users/dev/
    at Object.module.exports [as register] (/Users/dev/
    at Object.register (/Users/dev/
    at Object.register (/Users/dev/
    at async Strapi.runLifecyclesFunctions (/Users/dev/
    at async Strapi.register (/Users/dev/
    at async Strapi.load (/Users/dev/
error Command failed with exit code 1.

Things we tried:

  • deleting dist, lock files, node modules and cache and installing packages with both npm and yarn. Then trying to start the server with both. No luck.
  • Lowering version of strapi from 4.4.3 to 4.4.1 and retrying the step above again. Still no luck.
  • we added the patch package dependency, error persists.
  • we then tried reistalling, building the UI with npm run/yarn build and then starting the dev server. No luck again.

Things to keep in mind:

  • Project still runs on my colleague’s computer
  • Project still runs on a hosting provider
  • I tried creating a new strapi project with npx create-strapi-app@latest and it ran well.
  • I tried redownloading the whole project from git several times with patches from the colleague
  • I tried reinstalling yarn, node, typescript globally. I tried node 16.15.0, 16.13.2, 14.19.2 I tried running the command in internal and external terminal, different shells as well.

My System specs:

  • Node.js version: 16.15.0
  • NPM version: 8.5.5
  • Strapi version: 4.4.1 to 4.4.3
  • Operating system: MacOS Monterey 12.6

Colleague System specs:

  • Node.js version: 16.13.2
  • NPM version: 8.1.2
  • Strapi version: 4.4.1 to 4.4.3
  • Operating system: MacOS Monterey 12.6

Dependencies :

"scripts": {
    "develop": "strapi develop",
    "start": "strapi start",
    "build": "strapi build",
    "strapi": "strapi",
    "postinstall": "patch-package"
  "dependencies": {
    "@_sh/strapi-plugin-ckeditor": "^1.1.1",
    "@strapi/plugin-graphql": "^4.4.1", //first was 4.4.3
    "@strapi/plugin-i18n": "4.4.1", //first was 4.4.3
    "@strapi/plugin-seo": "^1.7.4",
    "@strapi/plugin-users-permissions": "4.4.1", //first was 4.4.3
    "@strapi/provider-email-sendgrid": "^4.4.1", //first was 4.4.3
    "@strapi/provider-upload-aws-s3": "^4.4.1", //first was 4.4.3
    "@strapi/strapi": "4.4.1", //first was 4.4.3
    "patch-package": "^6.4.7",
    "pg": "8.6.0",
    "strapi-plugin-menus": "^1.0.2",
    "strapi-plugin-vercel-deploy": "^1.3.1"

is the plugin in your repository when you try to install it on your machine?
I would start with a blank new project and gradually move the custom code into your project, reflecting the one you have in your repository.

Thanks for the feedback :blush: . We thought it was too much work to move bits of code back and forth between the new project and the buggy one, so we just started from scratch again and the problem has disappeared. I do not know what caused it in the first place, but it is gone now.