CLI generate api and uncomment code -Cannot read properties of undefined (reading 'forEach')

All i did is generate api and uncommented code in router forget to uncomment the controller

Error creating endpoint GET /user-activity-graph: Handler not found “user-activity-graph.exampleAction”
Error: Error creating endpoint GET /user-activity-graph: Handler not found “user-activity-graph.exampleAction”


after running yarn build and yarn develop i keep greeting this error even after commenting the code

[2022-12-07 08:49:55.607] debug: ⛔️ Server wasn't able to start properly.
[2022-12-07 08:49:55.609] error: Cannot read properties of undefined (reading 'forEach')
TypeError: Cannot read properties of undefined (reading 'forEach')
    at C:\v360PlasticProjects\Internal\BackendServices\strapi\headlesscms\node_modules\@strapi\strapi\lib\services\server\register-routes.js:98:21
    at C:\v360PlasticProjects\Internal\BackendServices\strapi\headlesscms\node_modules\lodash\lodash.js:4967:15
    at baseForOwn (C:\v360PlasticProjects\Internal\BackendServices\strapi\headlesscms\node_modules\lodash\lodash.js:3032:24)
    at C:\v360PlasticProjects\Internal\BackendServices\strapi\headlesscms\node_modules\lodash\lodash.js:4936:18
System Information
  • Strapi Version: 4.5.2
  • Operating System: windows 10
  • Database: mysql
  • Node Version:
  • NPM Version:
  • Yarn Version:

Checkout the SS attached.
I modified the file “mono_repo_root_folder/strapi/node_modules/@strapi/strapi/lib/services/server/register-routes.js” ,
in method const registerAPIRoutes = (strapi) => { … } , add a ‘?’ to router.routes.forEach((route) => {…} thereby converting it to router.routes?.forEach((route) => {…}
I used this to run it for time being. However, I still have not found any proper solution.
Let us know if you find anything Or know anything about the // TODO comment in node_module file.