Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading 'length') #1475

Open
Bortnyak opened this issue Jul 28, 2022 · 2 comments
Open

TypeError: Cannot read properties of undefined (reading 'length') #1475

Bortnyak opened this issue Jul 28, 2022 · 2 comments

Comments

@Bortnyak
Copy link

Sometimes I face this issue in different environments (ubuntu 20.04 and macOS Monterey):
'TypeError: Cannot read properties of undefined (reading 'length')'

Did anybody face the same issue?

Environment

  • Node v16.16.0 (tried 14/18 and got the same)
  • yarn v1.22.19
  • macOS Monterey
  • "inversify": "^5.0.1",
  • "inversify-express-utils": "6.3.2",

Stack trace

TypeError: Cannot read properties of undefined (reading 'length')
    at pathtoRegexp (/Users/volodymyr/Documents/repos/observe-api/node_modules/path-to-regexp/index.js:63:49)
    at new Layer (/Users/volodymyr/Documents/repos/observe-api/node_modules/inversify-express-utils/node_modules/express/lib/router/layer.js:45:17)
    at Function.use (/Users/volodymyr/Documents/repos/observe-api/node_modules/inversify-express-utils/node_modules/express/lib/router/index.js:464:17)
    at Function.<anonymous> (/Users/volodymyr/Documents/repos/observe-api/node_modules/inversify-express-utils/node_modules/express/lib/application.js:220:21)
    at Array.forEach (<anonymous>)
    at Function.use (/Users/volodymyr/Documents/repos/observe-api/node_modules/inversify-express-utils/node_modules/express/lib/application.js:217:7)
    at InversifyExpressServer.registerControllers (/Users/volodymyr/Documents/repos/observe-api/node_modules/inversify-express-utils/lib/server.js:161:19)
    at InversifyExpressServer.build (/Users/volodymyr/Documents/repos/observe-api/node_modules/inversify-express-utils/lib/server.js:121:14)
    at Object.<anonymous> (/Users/volodymyr/Documents/repos/observe-api/dist/App.js:68:18)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
error Command failed with exit code 1.
@Bortnyak
Copy link
Author

Figured out that this issue happens when do not specify the rootPath param. Here is my inversify server config

let server = new InversifyExpressServer(
  container,
  null,
  { rootPath: config.apiRootPath },
  null,
  null
);

Here I specified the rootPath param but forgot to set it in my config.

@notaphplover
Copy link
Member

Hey @Bortnyak, could provide a minimum reproduction code? Consider sharing a code sandbox or a repreoduction repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants