gpt4 book ai didi

node.js - puppeteer 类型 node_modules/puppeteer/lib/types "' has no exported member ' Cookie'

转载 作者:行者123 更新时间:2023-12-05 08:05:02 24 4
gpt4 key购买 nike

我遇到了 puppeteer 类型的问题,我正在尝试导入 Cookie 类型,但它不适用于高于 6.0.0 的版本。

import { Cookie } from 'puppeteer';

错误

/node_modules/puppeteer/lib/types"' has no exported member 'Cookie'.

最佳答案

如果您在 COVID 流行的世界中仍然受此困扰,

您可以使用类型文件定义您自己的类型,然后通过您的 tsconfig.json 导入它。当然,(在大多数情况下)不需要创建您自己的类型,您可以引用 @types/puppeteer 包并提取您需要的类型(但最新的 puppeteer 版本不包括)。我会让你自己找到 puppeteer 输入的乱七八糟的东西。

所以,如果我遇到一个 ... has no exported member HttpMethod 错误,我会创建一个类型文件,(例如 httpMethod.type.ts)以下内容取自@types/puppeteer:

export type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE' | 'OPTIONS';

确保新的类型文件位于低于 tsconfig.json 的文件夹中,以便它可以找到它。

然后,替换错误的导入行,例如:从 'puppeteer' 导入 { HttpMethod };

从 '../httpMethod.type' 导入 { HttpMethod };

关于node.js - puppeteer 类型 node_modules/puppeteer/lib/types "' has no exported member ' Cookie',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66275261/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com