Typescript __awaiter未定义

问题描述 投票:0回答:1

我正在尝试在页面内进行两个请求评估但我得到

Error: Evaluation failed: ReferenceError: __awaiter is not define at __puppeteer_evaluation_script

我有一个名为app.ts的文件:

 public async main() {
        this.browser = await puppeteer.launch({
            headless: config.get("puppeteer.headless"),
            args: config.get("puppeteer.args")
        });
        this.page = await this.browser.newPage();

        await this.page.evaluate(async () => {
            fetch("https://www.npmjs.com/features").then(response => response.text()).then(
                html => console.log(" Log within page"))
        }).catch(error => console.log(error));

    }

我得到的错误是这个:

    Error: Evaluation failed: ReferenceError: __awaiter is not defined
    at __puppeteer_evaluation_script__:1:16
    at ExecutionContext.evaluateHandle (/home/pap/Desktop/nodejs-project/node_modules/puppeteer/lib/ExecutionContext.js:124:13)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
    -- ASYNC --
    at ExecutionContext.<anonymous> (/home/pap/Desktop/nodejs-project/node_modules/puppeteer/lib/helper.js:144:27)
    at ExecutionContext.evaluate (/home/pap/Desktop/nodejs-project/node_modules/puppeteer/lib/ExecutionContext.js:58:31)
    at ExecutionContext.<anonymous> (/home/pap/Desktop/nodejs-project/node_modules/puppeteer/lib/helper.js:145:23)
    at Frame.evaluate (/home/pap/Desktop/nodejs-project/node_modules/puppeteer/lib/FrameManager.js:439:20)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
    -- ASYNC --
    at Frame.<anonymous> (/home/pap/Desktop/nodejs-project/node_modules/puppeteer/lib/helper.js:144:27)
    at Page.evaluate (/home/pap/Desktop/nodejs-project/node_modules/puppeteer/lib/Page.js:736:43)
    at Page.<anonymous> (/home/pap/Desktop/nodejs-project/node_modules/puppeteer/lib/helper.js:145:23)
    at app.<anonymous> (/home/pap/Desktop/nodejs-project/app.js:209:51)
    at step (/home/pap/Desktop/nodejs-project/app.js:32:23)
    at Object.next (/home/pap/Desktop/nodejs-project/app.js:13:53)
    at fulfilled (/home/pap/Desktop/nodejs-project/app.js:4:58)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

我试图在我添加的"noEmitHelpers": false的ts config上解决此问题,但仍未解决。尝试过importHelpers": true,但仍然遇到相同的问题。有帮助吗?

我的ts配置文件如下所示: { "compilerOptions": { "target": "es2017", "module": "commonjs", "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "sourceMap": true, "noEmitHelpers": false, "strictNullChecks": false, "typeRoots": [ "node_modules/@types" ] }, "compileOnSave": true, "exclude": [ "dist", "node_modules" ] } 我使用ts app.ts

将ts文件编译到节点js
javascript node.js typescript post get
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.