-
-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not find a declaration file for module 'uuid' (Incompatibility with ES6 Import) #668
Comments
From the error message:
Did you try this? For now you need to add the |
As I already mentioned that I did tried all possible solution to fix the error message but nothing works. Yes, I already tried the types installation solution but its not working. |
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 |
Yes, the same error occurs even after installing @types/uuid. The only solution that works for me that I tried is to create a new declaration file inside node_modules/uuid/ like node_modules/uuid/index.d.ts And add the following line to index.d.ts to fix the issue:
|
Hmm, I'm not able to reproduce this:
|
Yes, you're right I think the issue is within my project structure
|
I'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 itindex.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?
The text was updated successfully, but these errors were encountered: