Cannot find module '.' or its corresponding type declarations
See original GitHub issuewhen I use cheerio in my project with typescript, and try to compile it by tsc
. The compiler throws an exception described below:
error TS2307: Cannot find module '.' or its corresponding type declarations.
2 import type { CheerioAPI, Cheerio } from '.';
Found 1 error in node_modules/cheerio/lib/esm/static.d.ts:2
This seems to be a bug in the package itself. How should I solve this problem? Thanks.
And I only use cheerio in my project like this:
import * as cheerio from "cheerio";
cheerio.load(content) // The type of content is string.
“cheerio”: “^1.0.0-rc.12” “@types/cheerio”: “^0.22.31” node v16.16.0 npm v8.16.0
Issue Analytics
- State:
- Created a year ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Cannot find module 'react' or its corresponding type ...
The editor throws errors while importing every installed library like this: Cannot find module 'react' or its corresponding type declarations.
Read more >How to Solve cannot find module and its corresponding type ...
To solve cannot find module and its corresponding type declarations error in JavaScript, install that module and import the library in your ...
Read more >Error "Cannot find module 'react' or its corresponding type ...
Hi @johnjohn-0472,. According to my research and testing, please try to set moduleResolution to node in your tsconfig.json file. ... If the error ......
Read more >Cannot find module '...' or its corresponding type declarations.
/JwksManager.spec.ts:3:31 - error TS2307: Cannot find module 'jose' or its corresponding type declarations. 3 import { JWK as JWKLib } from ...
Read more >cannot find module 'vite' or its corresponding type declarations
To solve the "Cannot find module `path` or its corresponding type declarations" error, install the types for node by running the command `npm...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As a workaround, I recommend you to add the following to your
tsconfig.json
scompilerOptions
:This will use
cheerio
scjs
types instead of theesm
types. The type declarations look exactly the same so it fits as a workaround replacement perfectly well.Thanks for sending this by — the import should be updated to conform with ESM. I will make sure this is covered in the next release.