我有一个错误,这里的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button class="get" function="getInfo">Get Information</button>
<script src="../server/app.js"></script>
<script>
function getInfo() {
request('http://www.google.com', function (error, response, body) {
console.log('Status: ' + response && response.statusCode)
console.log('Body: ' + body)
})
}
</script>
</body>
</html>
这个错误很奇怪,你看:
<!DOCTYPE html>
^
SyntaxError: Unexpected token '<'
谢谢您的建议!对不起,英语不好!
发布于 2021-12-17 08:32:01
我不确定,但我认为您正在使用nodeJS运行html文件。
确保命令是node .\file.js
而不是node .\file.html
https://stackoverflow.com/questions/65416175
复制相似问题