Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail to excute node server.js #6

Open
Chambers1994 opened this issue Mar 23, 2020 · 2 comments
Open

fail to excute node server.js #6

Chambers1994 opened this issue Mar 23, 2020 · 2 comments

Comments

@Chambers1994
Copy link

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
Copy link

ZhuoSir commented May 2, 2024

解决了吗

@woeinsd
Copy link

woeinsd commented Nov 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants