Open Chambers1994 opened 4 years ago
解决了吗
我也遇到这个问题 app.use(express.static(path.join(__dirname, 'public')), null);修改为
app.use(express.static(path.join(__dirname, 'public')));
express.static(path.join(dirname, 'public')):这是一个中间件函数,用于提供 public 目录中的静态文件。path.join(dirname, 'public') 会生成 public 目录的绝对路径。 app.use(...):将这个中间件添加到 Express 应用中,使得所有请求都可以访问 public 目录中的文件。 , null:这个部分是多余的,因为 app.use() 只需要一个中间件函数作为参数。传递 null 会导致您之前遇到的错误。 为了修复这个问题,您可以将代码修改为:
I hava try twice, but it didn't work, I config my /etc/turnserver.conf based this github guidance, but then: air@air-G3-3590:~/webRTC/webrtc_server$ node server.js /home/air/webRTC/webrtc_server/node_modules/express/lib/router/index.js:458 throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn)) ^
TypeError: Router.use() requires a middleware function but got a Null at Function.use (/home/air/webRTC/webrtc_server/node_modules/express/lib/router/index.js:458:13) at Function. (/home/air/webRTC/webrtc_server/node_modules/express/lib/application.js:220:21)
at Array.forEach ()
at Function.use (/home/air/webRTC/webrtc_server/node_modules/express/lib/application.js:217:7)
at Object. (/home/air/webRTC/webrtc_server/server.js:9:5)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
air@air-G3-3590:~/webRTC/webrtc_server$ node server.js
Your help will be appreciated!