什么是 TypeError: require(...)(...) is not a function 当我尝试运行我的 playWright 脚本时?

时间:2021-02-25 21:26:00

标签: javascript playwright

我目前正在将自动化脚本的一部分移动到不同的文件中以更轻松地维护整个脚本,但我遇到了这个问题。

$ node ./playWright/index
    D:\Lambda\projects\puppeteer_test\playWright\index.js:6
    })();
  ^

TypeError: require(...)(...) is not a function
    at Object.<anonymous> (D:\Lambda\projects\puppeteer_test\playWright\index.js:6:3)

1 个答案:

答案 0 :(得分:0)

转换你的 index.js 启动函数

(async () => { // Start of async arrow function
  // Function code
  // ...
})(); // End of the function and () to invoke itself

到一个普通的异步函数

async function index() {
  await downloadFile()
  console.log("Test")
}