当我在我的项目中使用 typescript 使用 Cheerio 时,并尝试通过 tsc 编译它。编译器抛出如下异常:
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
Run Code Online (Sandbox Code Playgroud)
这似乎是包本身的错误。我应该如何解决这个问题?谢谢。
我只在我的项目中使用cheerio,如下所示:
import * as cheerio from "cheerio";
cheerio.load(content) // The type of content is string.
Run Code Online (Sandbox Code Playgroud)
"cheerio": "^1.0.0-rc.12""@types/cheerio": "^0.22.31"node v16.16.0npm v8.16.0