ddssingsong / webrtc_server_node

videoCall VideoConference 视频通话 视频会议
https://blog.csdn.net/u011077027/article/details/86225524
370 stars 184 forks source link

fail to excute node server.js #6

Open Chambers1994 opened 4 years ago

Chambers1994 commented 4 years ago

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!

ZhuoSir commented 6 months ago

解决了吗

woeinsd commented 1 week 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 会导致您之前遇到的错误。 为了修复这个问题,您可以将代码修改为: