I made test.js and testweb.html.
this is test.js
const main = async () => {
console.log("main!");
};
async function test(){
const puppeteer = require('puppeteer');
let page;
const browser = await puppeteer.launch({
headless : false
});
page = await browser.newPage();
await page.goto('https://www.google.com/', {waitUntil:'networkidle2'});
console.log("test()!");
}
main();
this is testweb.html
<!DOCTYPE html>
<html>
<head>
<title>test web page</title>
</head>
<body>
<input type="button" title="login" alt="login" value="subject" class="btn" id="log.login" onclick = "test()">
<script type="text/javascript" language="javascript" src ="./test.js"></script>
</body>
When running the html code, the following error occurs :Uncaught (in promise) ReferenceError: require is not defined
It's difficult for me to solve this. If you can solve this problem, please let me know the solution. :(