Could not find a declaration file for module 'uuid' (Incompatibility with ES6 Import)
See original GitHub issueI’m using TypeScript inside my project. If I try to use ES5 import style like
const { v4: uuidv4 } = require('uuid');
So I don’t get any error while compilation but when I convert it into ES6 style like
import { v4 as uuidv4 } from 'uuid';
I get a compilation error like
Could not find a declaration file for module 'uuid'. 'C:/Users/project/dependencies/nodejs/node_modules/uuid/dist/index.js' implicitly has an 'any' type. Try 'npm i --save-dev @types/uuid' if it exists or add a new declaration (.d.ts) file containing 'declare module 'uuid';'
I tried the available solutions to fix this kind of error but nothing worked. In the end I created a new declaration file inside node_modules/uuid/
and named it index.d.ts
And add the following line to fix the issue:
declare module 'uuid';
And then the error is gone.
Can anyone fix this type of issue?
Issue Analytics
- State:
- Created 9 months ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Hmm, I’m not able to reproduce this:
It’s impossible for me to know what you mean with “all possible solution” 😅 If you mean that literally, then there is nothing I can do to help since all the possible solutions are already tried…
After installing
@types/uuid
, do you still get the exact same error message?