我收到这个奇怪的错误,它指向我的声明,但不知道如何修复它。
所以最初,我正在创建一个小项目来帮助我学习 Web 开发。我最初将该项目作为静态网页启动,但决定将其连接到服务器,因为我需要使用 npm api 包 (yelp-node)。这是我的服务器端代码,用于读取我的 html 文件。
https://jsfiddle.net/hgcm3w27/
var http = require('http');
var path = require('path');
var fs = require('fs');
var verifyMimeType = true;
var port = 8000;
var serverURL = "127.0.0.1";
console.log("Starting web server: " + serverURL + ":" + port);
var server = http.createServer(function(req,res){
// set to URL or default to index.html
var filename = "/index.html"
console.log("Filename is: " + filename);
// sets the extention of the filename
var ext = path.extname(filename);
var localPath = …Run Code Online (Sandbox Code Playgroud)