nestjs-minio-client
nestjs-minio-client copied to clipboard
Nest can't resolve dependencies of the MinioService (?)
Nest can't resolve dependencies of the MinioService (?). Please make sure that the argument minioCfgOptions at index [0] is available in the UsersModule context.
Potential solutions:
- If __minioCfgOptions__ is a provider, is it part of the current UsersModule?
- If __minioCfgOptions__ is exported from a separate @Module, is that module imported within UsersModule?
@Module({
imports: [ /* the Module containing __minioCfgOptions__ */ ]
})
Error: Nest can't resolve dependencies of the MinioService (?). Please make sure that the argument __minioCfgOptions__ at index [0] is available in the UsersModule context.
I had the same problem today. It appears that you need to do the import: [MinioModule.register(...)]
call in every module where you want to use it. So, the advice to register it in app.module
only works if you intend to use it only in app.service
I was expecting it to work like CacheModule
- register it once app.module
and then inject it into the constructor of any service which needs it.
Same problem here.
Sorry people I will update it today haven’t got much time lately.
On Fri, Apr 8, 2022 at 18:47 Ron Arts @.***> wrote:
Same problem here.
— Reply to this email directly, view it on GitHub https://github.com/djedlajn/nestjs-minio-client/issues/19#issuecomment-1093080993, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACEYNEWUCBIH5MHOMLDOF3LVEBPLLANCNFSM5OHGCPHQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Any Update on this issue. I have the same issue with dependencies of the MinioService
Hello,
I have added a new option global
so that when you register your module if you pass it will be namespaced to global and thus you won't need to import the Minio module in another module. Available in v1.2.0
.
Example
MinioModule.register({
global: true, <---
endPoint: '127.0.0.1',
port: 9000,
useSSL: false,
accessKey: 'minioadmin',
secretKey: 'minioadmin',
})

Still same error after defining global variable
You have to register it in AppModule or somewhere else.
Take a look at https://github.com/djedlajn/minio-ex
Registered MinioModule in AppModule with global
set to true and using it as service in Arc controller.
I also encountered this issue. I guess this problem come, when you want the module global with registerAsync.
Same issue here. Any potential update @djedlajn ? The minio-ex link is broken btw
Hello,
I plan on releasing major update providing built support for v9 nest in which aforementioned issues will be fixed. It may happen today or tomorrow.
On Fri, Aug 19, 2022 at 13:39 GIGOU @.***> wrote:
Same issue here. Any potential update @djedlajn https://github.com/djedlajn ? The minio-ex link is broken btw
— Reply to this email directly, view it on GitHub https://github.com/djedlajn/nestjs-minio-client/issues/19#issuecomment-1220573883, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACEYNEWV55NQJAD6UEC7Q5DVZ5W7XANCNFSM5OHGCPHQ . You are receiving this because you were mentioned.Message ID: @.***>
Great news, I've opened PR #25 for a brand new major version, supporting nest v9, addressing all of the mentioned problems and refactoring the overall architecture of the library.
Global configuration examples
MinioModule.registerAsync({
useFactory: () => ({
endPoint: '127.0.0.1',
port: 9000,
useSSL: false,
accessKey: 'ACCESS_KEY',
secretKey: 'SECRET_KEY',
}),
isGlobal: true,
}),
MinioModule.register({
endPoint: '127.0.0.1',
port: 9000,
useSSL: false,
accessKey: 'ACCESS_KEY',
secretKey: 'SECRET_KEY',
isGlobal: true,
}),
We are waiting on @djedlajn to run through the changes and make a new release.
@kdopen @raarts @gigouni @Twois @sohana08 @lamasagar I've released the new major version (2.0.0), please check out the comment above and the slightly altered docs. Also, I'd appreciate the feedback if the issues are resolved.
@rejvban
How Would I set up unit tests with netjs-minio-client?
The default generated test with included imports for minio can't resolve the dependency to MinioConfigService:
import { Test, TestingModule } from "@nestjs/testing";
import { AttachmentsService } from "./attachments.service";
import {MinioModule, MinioService} from "nestjs-minio-client";
describe("AttachmentsService", () => {
let service: AttachmentsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [MinioModule],
providers: [AttachmentsService, MinioService],
}).compile();
service = module.get<AttachmentsService>(AttachmentsService);
});
it("should be defined", () => {
expect(service).toBeDefined();
});
});
@kdopen @raarts @gigouni @Twois @sohana08 @lamasagar I've released the new major version (2.0.0), please check out the comment above and the slightly altered docs. Also, I'd appreciate the feedback if the issues are resolved.
I have been using aws-sdk for minio client credentials till now. Will try with MinioService soon
@kdopen @raarts @gigouni @Twois @sohana08 @lamasagar I've released the new major version (2.0.0), please check out the comment above and the slightly altered docs. Also, I'd appreciate the feedback if the issues are resolved.
I've install the 2.0.0 version and I may have missed something but it leads to errors here.
My buckets.module.ts

(Roughly translated message: The "register" property does not exist on type MinioModule)
There is an issue with the test file too. An example below

And its result

Did I miss something?
Closing as the root issue is resolved, for anyone who branched beyond this, please open a separate one.