@nestjs/swagger and bson lib collision problem
See original GitHub issueI’m submitting a Bug report
[ ] 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.
import { PrimaryKey, Property, SerializedPrimaryKey } from '@mikro-orm/core';
import { ObjectId } from 'bson';
export abstract class CommonEntity {
@PrimaryKey()
_id: ObjectId;
@SerializedPrimaryKey()
id!: string; // string variant of PK, will be handled automatically
@Property()
createdAt = new Date();
@Property({ onUpdate: () => new Date() })
updatedAt = new Date();
}
{
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"projects": {},
"compilerOptions": {
"webpack": false,
"plugins": [
{
"name": "@nestjs/swagger",
"options": {
"classValidatorShim": true,
"introspectComments": true
}
}
]
}
}
Current behavior
Error: Cannot find module ‘bson/bson’ Require stack:
- /Volumes/HD/workspace/_temp/hello-nest/dist/src/entities/common.entity.js
- /Volumes/HD/workspace/_temp/hello-nest/dist/src/modules/users/entities/user.entity.js
- /Volumes/HD/workspace/_temp/hello-nest/dist/src/modules/users/users.service.js
- /Volumes/HD/workspace/_temp/hello-nest/dist/src/modules/users/users.module.js
- /Volumes/HD/workspace/_temp/hello-nest/dist/src/app.module.js
- /Volumes/HD/workspace/_temp/hello-nest/dist/src/main.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:15)
Expected behavior
Expected import bson,dont bson/bson
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
npm i npm run start
Environment
Nest version: 8.0
For Tooling issues:
- Node version: node 16
- Platform: mac 15
Others:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:18 (3 by maintainers)
Top Results From Across the Web
OpenAPI (Swagger) | NestJS - A progressive Node.js framework
Hint To generate and download a Swagger JSON file, navigate to ... there may be a problem with CSP, to solve this collision,...
Read more >Nest + Swagger not recognizing endpoints or parameters
Ultimately I think the issue is: Swagger + Nest is not creating unique operationId 's for each method. My understanding is that methods...
Read more >Multiple messages for the same http status code not displayed.
I was able to generate swagger API documentation for my restful services that use Jboss and resteasy. The only issue i am facing...
Read more >NestJS — The Hero We Didn't Know We Needed - SingleStone
One problem with our Swagger UI docs is that it does not define enough of our endpoints. If you scaffold another feature it...
Read more >Publishing NestJS Packages with npm - DEV Community
Hello first great the article just a question after following the steps install @ nestjs / swagger, but it gives me an error...
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
This appears to be an issue with the CLI Plugin. I was able to solve this issue by removing the
@nestjs/swagger
plugin declaration from thenest-cli.json
file. We have declared decorators manually so the plugin was not needed. As soon as it was removed, this problem went away.Did you run mongodb instance locally? Without that the orm wont bootup You can see here the logs https://imgur.com/a/K7VbNCL @micalevisk