Skip to content
Advertisement

error TS2688: Cannot find type definition file for ‘ioredis’

I have a project with nestJS. But in when trying to add some module it show error.

error TS2688: Cannot find type definition file for 'ioredis'.
  The file is in the program because:
    Entry point for implicit type library 'ioredis'

and this is my tsconfig

{
    "compilerOptions": {
        "module": "commonjs",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "noLib": false,
        "allowSyntheticDefaultImports": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "target": "es2017",
        "sourceMap": true,
        "allowJs": true,
        "outDir": "./dist",
        "baseUrl": "./",   
        "paths": {
            "@core/*": ["src/core/*"],
            "@main/*": ["src/main/*"],
            "@migrations/*": ["src/migrations/*"],
            "@modules/*": ["src/modules/*"],
            "@shared/*": ["src/shared/*"]
        },
        "incremental": true
    },
    "exclude": [
        "node_modules", "dist"
    ]
}

How to resolve the error ?

Advertisement

Answer

If you’re on ioredis@4, it comes without built-in TypeScript definitions. You’ll have to install @types/ioredis:

npm install --save-dev @types/ioredis@4.28.10

If you’re on ioredis@5 and use @nestjs/bull, the bull package does not support ioredis@5. You’ll have to downgrade ioredis:

npm install --save ioredis@4.28.5
npm install --save-dev @types/ioredis@4.28.10
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement