Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 获取错误路由上的错误_Javascript_Node.js_Express - Fatal编程技术网

Javascript 获取错误路由上的错误

Javascript 获取错误路由上的错误,javascript,node.js,express,Javascript,Node.js,Express,当我运行节点服务器时出现错误,无法找出根本原因。我正在粘贴下面的错误。我非常感谢您的帮助,因为我花了很多时间浏览了堆栈溢出帖子,并试图调试这个问题。多谢各位 错误: C:\Users\desktop\studentSearch\node_modules\express\lib\router\index.js:458 throw new TypeError('Router.use() requires middleware function but got a ' + gettype(

当我运行
节点服务器时
出现错误,无法找出根本原因。我正在粘贴下面的错误。我非常感谢您的帮助,因为我花了很多时间浏览了堆栈溢出帖子,并试图调试这个问题。多谢各位

错误:

C:\Users\desktop\studentSearch\node_modules\express\lib\router\index.js:458
      throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn));
      ^

TypeError: Router.use() requires middleware function but got a undefined
    at Function.use (C:\Users\Monica\desktop\studentSearch\node_modules\express\lib\router\index.js:458:13)
    at Function.<anonymous> (C:\Users\Monica\desktop\studentSearch\node_modules\express\lib\application.js:220:21)
    at Array.forEach (native)
    at Function.use (C:\Users\Monica\desktop\studentSearch\node_modules\express\lib\application.js:217:7)
    at Object.<anonymous> (C:\Users\Monica\desktop\studentSearch\server.js:46:5)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3
问题在于定义中有(应用程序)。见下文

var apiRoutes = require("./routes/api-routes.js")(app); 

如果您不发布代码,我们将无法帮助您。谢谢!我刚刚添加了它。看起来进入
use
的函数之一未定义,例如
app.use(“/”,apirouts)。这里定义了apirouts
吗?谢谢。这个问题实际上是我定义它的方式,因为在定义之后我有(app)。我真的很感谢你的帮助。
var apiRoutes = require("./routes/api-routes.js")(app);