Javascript nodejs中存在类型错误的未处理PromisejectionWarning

Javascript nodejs中存在类型错误的未处理PromisejectionWarning,javascript,node.js,express,node-modules,Javascript,Node.js,Express,Node Modules,在nodejs中运行node server.js时,错误消息显示“无法读取未定义的属性”length”。我已经安装了所有相关的库(例如request),并查看了不同的相关帖子。然而,这个问题仍然存在。 我认为它与express或索引文件有关。 有什么建议吗? 非常感谢 (node:14320) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined at pathtoRegex

在nodejs中运行node server.js时,错误消息显示“无法读取未定义的属性”length”。我已经安装了所有相关的库(例如request),并查看了不同的相关帖子。然而,这个问题仍然存在。 我认为它与express或索引文件有关。 有什么建议吗? 非常感谢

(node:14320) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
at pathtoRegexp (/home/floyd/Desktop/icigai/marketplace_backend/node_modules/path-to-regexp/index.js:63:49)
at new Layer (/home/floyd/Desktop/icigai/marketplace_backend/node_modules/express/lib/router/layer.js:45:17)
at Function.use (/home/floyd/Desktop/icigai/marketplace_backend/node_modules/express/lib/router/index.js:464:17)
at Function.<anonymous> (/home/floyd/Desktop/icigai/marketplace_backend/node_modules/express/lib/application.js:220:21)
at Array.forEach (<anonymous>)
at Function.use (/home/floyd/Desktop/icigai/marketplace_backend/node_modules/express/lib/application.js:217:7)
at _default (/home/floyd/Desktop/icigai/marketplace_backend/src/loaders/express.js:28:9)
at _callee$ (/home/floyd/Desktop/icigai/marketplace_backend/src/loaders/index.js:8:11)
at tryCatch (/home/floyd/Desktop/icigai/marketplace_backend/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/home/floyd/Desktop/icigai/marketplace_backend/node_modules/regenerator-runtime/runtime.js:293:22)

(node:14320) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

未定义
null
值传递给
app.use将导致显示的错误。因此,我猜您使用的env变量有问题,例如:

app.use(process.env.ROUTING_PREFIX, routes.default);

尝试执行
console.log(process.env.ROUTING_PREFIX)
并检查该值是否已设置或
未定义