TypeScript - Puppeteer 库错误:“找不到名称‘元素’"; [英] TypeScript - Puppeteer library error: "Cannot find name 'Element'"

查看:64
本文介绍了TypeScript - Puppeteer 库错误:“找不到名称‘元素’";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 puppeteer-core 作为依赖项包含在我的 TypeScript 项目中,并且正在使用 Visual Studio 2019.当我尝试构建项目时,出现以下错误(如红色所示Element 下的波浪线下划线):

I have included puppeteer-core as a dependency in my TypeScript project, and am using Visual Studio 2019. When I try to build the project, I get this error below (as shown by the red squiggly underline under Element):

错误 TS2304:构建:找不到名称元素"

error TS2304: Build:Cannot find name 'Element'

请问我该如何解决?

推荐答案

dom 添加到我的 tsconfig.json库数组 通过在 DOM 库:

Adding dom to my tsconfig.json's array of libraries fixed the issue by compiling in the DOM library:

{
    "compilerOptions": {
        "lib": [
            "es2018",
            "dom"
        ]
    }
}

这篇关于TypeScript - Puppeteer 库错误:“找不到名称‘元素’";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆