简体   繁体   中英

What is the TypeError: require(…)(…) is not a function when I try to run my playWright script?

I am currently moving parts of my automation scripts to different files to maintain the whole script more easily, and I encounter this issue.

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

Convert your index.js startup function from

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

To a normal async function

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM