小编Poi*_*son的帖子

找不到模块“。” 或其相应的类型声明

当我在我的项目中使用 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.0 npm v8.16.0

node.js npm typescript cheerio es6-modules

5
推荐指数
1
解决办法
4268
查看次数

标签 统计

cheerio ×1

es6-modules ×1

node.js ×1

npm ×1

typescript ×1