TypeError: pathToRegexp.parse
See original GitHub issueI’m submitting a…
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
swagger doesn’t work with tsconfig-paths
Minimal reproduction of the problem with instructions
For example i set path in tsconfig
"paths": {
"*": [
"node_modules/*"
],
"@services/*": [
"src/services/*"
],
"@controllers/*": [
"src/controllers/*"
],
"@middleware/*": [
"src/middleware/*"
],
"@models/*": [
"src/models/*"
],
"@helper/*": [
"src/helper/*"
]
}
Set build swagger in main func
const options = new DocumentBuilder()
.setTitle('Cats example')
.setDescription('The cats API description')
.setVersion('1.0')
.addTag('cats')
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
If i replace all import paths to controller(import {SomeController} from “@controllers/SomeController.ts” for exml) get throw
(node:15288) UnhandledPromiseRejectionWarning: TypeError: pathToRegexp.parse(...) is not a function or its return value is not iterable
at SwaggerExplorer.validateRoutePath (C:\projects\test\nest-app\node_modules\@nestjs\swagger\dist\swagger-explorer.js:107:41)
at SwaggerExplorer.generateDenormalizedDocument (C:\projects\test\nest-app\node_modules\@nestjs\swagger\dist\swagger-explorer.js:42:25)
at SwaggerExplorer.exploreController (C:\projects\test\nest-app\node_modules\@nestjs\swagger\dist\swagger-explorer.js:36:21)
at denormalizedArray.map.ctrl (C:\projects\test\nest-app\node_modules\@nestjs\swagger\dist\swagger-scanner.js:33:82)
at Array.map (<anonymous>)
at SwaggerScanner.scanModuleRoutes (C:\projects\test\nest-app\node_modules\@nestjs\swagger\dist\swagger-scanner.js:33:56)
at modules.map (C:\projects\test\nest-app\node_modules\@nestjs\swagger\dist\swagger-scanner.js:28:25)
at Array.map (<anonymous>)
at SwaggerScanner.scanApplication (C:\projects\test\nest-app\node_modules\@nestjs\swagger\dist\swagger-scanner.js:15:43)
at Function.createDocument (C:\projects\test\nest-app\node_modules\@nestjs\swagger\dist\swagger-module.js:8:41)
Environment
Nest swagger version: 3.1.0
Nest version: 6.5.3
tsconfig-paths version: 3.8.0
For Tooling issues:
- Node version: 10.16.0
- Platform: Windows
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top Results From Across the Web
path-to-regexp - npm
Express style path to RegExp utility. Latest version: 6.2.1, last published: 8 months ago. Start using path-to-regexp in your project by ...
Read more >'path-to-regexp' does not contain a default export (imported as ...
I solved this by simply reverting back to the old version of path-to-regex.To do that simply run this: npm i path-to-regexp@2.4.0 --save.
Read more >react-router - UNPKG
node_modules/path-to-regexp/node_modules/isarray/index.js",". ... null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with ...
Read more >How to use the path-to-regexp.compile function in path ... - Snyk
parse (url); url = pathToRegexp.compile(url)(data); for (const item of match) { // eslint-disable-next-line ...
Read more >server/node_modules/path-to-regexp ... - GitLab
var pathToRegexp = require('path-to-regexp') // pathToRegexp(path, keys, options) // pathToRegexp.parse(path) // pathToRegexp.compile(path).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh, sorry… My mistake. The problem was not in the package version. tsconfig was incorrect.
this throw error delete this option solve my problem
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.