I have a project with nestJS. But in when trying to add some module it show error.
JavaScript
x
4
1
error TS2688: Cannot find type definition file for 'ioredis'.
2
The file is in the program because:
3
Entry point for implicit type library 'ioredis'
4
and this is my tsconfig
JavaScript
1
29
29
1
{
2
"compilerOptions": {
3
"module": "commonjs",
4
"declaration": false,
5
"noImplicitAny": false,
6
"removeComments": true,
7
"noLib": false,
8
"allowSyntheticDefaultImports": true,
9
"emitDecoratorMetadata": true,
10
"experimentalDecorators": true,
11
"target": "es2017",
12
"sourceMap": true,
13
"allowJs": true,
14
"outDir": "./dist",
15
"baseUrl": "./",
16
"paths": {
17
"@core/*": ["src/core/*"],
18
"@main/*": ["src/main/*"],
19
"@migrations/*": ["src/migrations/*"],
20
"@modules/*": ["src/modules/*"],
21
"@shared/*": ["src/shared/*"]
22
},
23
"incremental": true
24
},
25
"exclude": [
26
"node_modules", "dist"
27
]
28
}
29
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
:
JavaScript
1
2
1
npm install --save-dev @types/ioredis@4.28.10
2
If you’re on ioredis@5
and use @nestjs/bull
, the bull
package does not support ioredis@5
. You’ll have to downgrade ioredis
:
JavaScript
1
3
1
npm install --save ioredis@4.28.5
2
npm install --save-dev @types/ioredis@4.28.10
3