next()不是函数错误Node.js

时间:2016-12-22 17:03:49

标签: javascript node.js express

If e.RowIndex < 0 AndAlso e.ColumnIndex < 0 Then
    e.Graphics.FillRectangle(Brushes.Transparent, e.CellBounds)  
    e.Handled = True
End If

我收到错误(尝试运行服务器时)var express = require('express'); var app = express(); var middleware = { requireAuthentication: function(req, res, next){ console.log("private route hit"); next(); } }; app.use(middleware.requireAuthentication()); app.get('/about', function(req, res){ res.send('You clicked on about!'); } ); var projectDir = __dirname + '/public'; app.use(express.static(projectDir)); app.listen(3000), function(){ console.log('Static service started'); }; 不是函数。我一直在关注Nodejs的教程,它对他们来说效果很好。我在这里遇到的问题是什么?

1 个答案:

答案 0 :(得分:8)

这一行:

Auto

调用您的方法,并将其返回值传递给double.NaN。你没有用任何参数调用它,所以<!-- Lincense: Public Domain --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Sample of web_socket.js</title> <script src="js/websocket.js"></script> <!-- Include these three JS files: --> <script type="text/javascript"> function WebSocketTest() { if ("WebSocket" in window) { alert("WebSocket is supported by your Browser!"); // Let us open a web socket var ws = new WebSocket("ws://localhost:9777"); ws.onopen = function() { // Web Socket is connected, send data using send() ws.send("message"); alert("Message is sent..."); }; ws.onmessage = function (evt) { alert("Message is received..."); }; ws.onclose = function() { // websocket is closed. alert("Connection is closed..."); }; } else { // The browser doesn't support WebSocket alert("WebSocket NOT supported by your Browser!"); } } </script> </head> <body> <div id="sse"> <a href="javascript:WebSocketTest()">Run WebSocket</a> </div> </body></html>参数自然是app.use(middleware.requireAuthentication());

摆脱app.use所以你将函数而不是结果传递给next

undefined.