TypeScript - Puppeteer library error: “Cannot find

2020-08-26 04:25发布

问题:

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):

error TS2304: Build:Cannot find name 'Element'

How can I resolve this please?

回答1:

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

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