Is there an existing issue for this?
Current behavior
When using nestjs/swagger with this minimal example in a folder containing a non-ASCII character, I get errors "Cannot find module":
node:internal/modules/cjs/loader:1413
throw err;
^
Error: Cannot find module '/mnt/Data/testnéstcli/testcli/src/dto/test.dto'
Require stack:
- /mnt/Data/testnéstcli/testcli/dist/app.controller.js
- /mnt/Data/testnéstcli/testcli/dist/app.module.js
- /mnt/Data/testnéstcli/testcli/dist/main.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1410:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1051:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1056:22)
at Module._load (node:internal/modules/cjs/loader:1219:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:238:24)
at Module.require (node:internal/modules/cjs/loader:1493:12)
at require (node:internal/modules/helpers:152:16)
at Object.<anonymous> (/mnt/Data/testnéstcli/testcli/src/app.controller.ts:13:17)
at Module._compile (node:internal/modules/cjs/loader:1738:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/mnt/Data/testnéstcli/testcli/dist/app.controller.js',
'/mnt/Data/testnéstcli/testcli/dist/app.module.js',
'/mnt/Data/testnéstcli/testcli/dist/main.js'
]
}
When digging to understand the error, it comes from the generated app.controller.js:
exports.AppController = AppController;
__decorate([
(0, swagger_1.ApiOperation)({ summary: 'Hello' }),
(0, swagger_1.ApiResponse)({ status: 200 }),
(0, common_1.Get)('/hello'),
openapi.ApiResponse({ status: 200, type: [require("/mnt/Data/testnéstcli/testcli/src/dto/test.dto").TestDto] }),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], AppController.prototype, "getHello", null);
Note that the error is also in the generated test.dto.js, regarding the enum type (removing this enum property still yields the other error):
const test_entity_1 = require("../entities/test.entity");
class TestDto {
id;
name;
enum;
static _OPENAPI_METADATA_FACTORY() {
return { id: { required: true, type: () => Number }, name: { required: true, type: () => String },
enum: { required: true, enum: require("/mnt/Data/testnéstcli/testcli/src/entities/test.entity").TestEnum } };
}
}
The issue is solved as soon as I remove the swagger plugin from nest-cli.json (which removes the _OPENAPI_METADATA_FACTORY, and lets the field type of AppController be defined by the @ApiResponse).
It is also solved if I rename "testnéstcli" to "testnestcli"
Minimum reproduction code
https://github.com/Evarin/nestjs-swagger-path-issue
Install it in a folder with non-ASCII character, e.g. "tést".
Steps to reproduce
No response
Expected behavior
The generated paths should be relative, and point to the generated version instead of the typescript source: ../entities/test.entity instead of /mnt/Data/testnéstcli/testcli/src/entities/test.entity
Probably related to #3162, but more general?
It seems not to happen on Windows, as I had the original issue on a more comprehensive repo made by someone working on Windows.
Package version
11.2.5
NestJS version
11.1.12
Node.js version
24.5.0
In which operating systems have you tested?
Other
No response
Is there an existing issue for this?
Current behavior
When using
nestjs/swaggerwith this minimal example in a folder containing a non-ASCII character, I get errors "Cannot find module":When digging to understand the error, it comes from the generated
app.controller.js:Note that the error is also in the generated
test.dto.js, regarding the enum type (removing this enum property still yields the other error):The issue is solved as soon as I remove the swagger plugin from
nest-cli.json(which removes the_OPENAPI_METADATA_FACTORY, and lets the fieldtypeofAppControllerbe defined by the@ApiResponse).It is also solved if I rename "testnéstcli" to "testnestcli"
Minimum reproduction code
https://github.com/Evarin/nestjs-swagger-path-issue
Install it in a folder with non-ASCII character, e.g. "tést".
Steps to reproduce
No response
Expected behavior
The generated paths should be relative, and point to the generated version instead of the typescript source:
../entities/test.entityinstead of/mnt/Data/testnéstcli/testcli/src/entities/test.entityProbably related to #3162, but more general?
It seems not to happen on Windows, as I had the original issue on a more comprehensive repo made by someone working on Windows.
Package version
11.2.5
NestJS version
11.1.12
Node.js version
24.5.0
In which operating systems have you tested?
Other
No response