nest-modules / ioredis

:see_no_evil: :hear_no_evil: :speak_no_evil: A ioredis module for Nest framework (node.js)
MIT License
145 stars 31 forks source link

Issue with Redis module export after reinstalling node_modules #279

Closed anassarfraz closed 11 months ago

anassarfraz commented 11 months ago

Issue with Redis module export after reinstalling node_modules

Overview

After deleting th node_modules directory and reinstalling it using npm i --force, I encountered an issue with the Redis module in @nestjs-modules/ioredis. The specific error is as follows:

src/redis-cache/redis-cache.service.ts:2:23 - error TS2305: Module '"@nestjs-modules/ioredis"' has no exported member 'Redis'.

2 import { InjectRedis, Redis } from "@nestjs-modules/ioredis";
                        ~~~~~

Steps to Reproduce

  1. Delete node_modules directory.
  2. Run npm i --force to reinstall dependencies.
  3. Attempt to run the NestJS project.

Expected Behavior

I expected the project to run successfully without any issues related to the @nestjs-modules/ioredis module.

Current Behavior

The project fails to compile with the mentioned TypeScript error regarding the missing exported member 'Redis' in @nestjs-modules/ioredis.

Environment

@nestjs-modules/ioredis version

Code Changes in node_modules redis.interface.d.ts

Before delete node modules (file node_modules/@nestjs-modules/ioredis/dist/redis.interface.d.ts)

import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
import * as Redis from 'ioredis';
export declare type Redis = Redis.Redis;
export interface RedisModuleOptions {
    config: Redis.RedisOptions & {
        url?: string;
    };
}
export interface RedisModuleOptionsFactory {
    createRedisModuleOptions(): Promise<RedisModuleOptions> | RedisModuleOptions;
}
export interface RedisModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
    inject?: any[];
    useClass?: Type<RedisModuleOptionsFactory>;
    useExisting?: Type<RedisModuleOptionsFactory>;
    useFactory?: (...args: any[]) => Promise<RedisModuleOptions> | RedisModuleOptions;
}

After install node modules (file node_modules/@nestjs-modules/ioredis/dist/redis.interface.d.ts)


import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
import { RedisOptions } from 'ioredis';
export interface RedisModuleOptions {
    config: RedisOptions & {
        url?: string;
    };
}
export interface RedisModuleOptionsFactory {
    createRedisModuleOptions(): Promise<RedisModuleOptions> | RedisModuleOptions;
}
export interface RedisModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
    inject?: any[];
    useClass?: Type<RedisModuleOptionsFactory>;
    useExisting?: Type<RedisModuleOptionsFactory>;
    useFactory?: (...args: any[]) => Promise<RedisModuleOptions> | RedisModuleOptions;
}

Additional Information

I prefer not to update the version of @nestjs-modules/ioredis but seek guidance on resolving the issue without a version change.

Reproducibility

Severity

Attachments

Before and after interface file with same version image

Due to changes in interface i am getting in import of redis in my service image

Error i am getting image

Additional Notes

I think i am getting these issues after updates in @nestjs-modules/ioredis

Labels

Assignees

juandav commented 11 months ago

Now you must use it in this way, note that Redis is imported from the 'ioredis' library.

image
anassarfraz commented 11 months ago

@juandav thanks for response

I resolved this issue with remove ^ sign from version number ("@nestjs-modules/ioredis": "^1.0.1", -------> "@nestjs-modules/ioredis": "1.0.1").

juandav commented 11 months ago

@anassarfraz Although you could use the new version of @nestjs-modules/ioredis, version 2.0.1.

anassarfraz commented 11 months ago

@juandav yes i used newer version but i got more errors because my nestjs Version 7.0.0 new i am shifting my project to updated packages. thanks