亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Nodejs 中出現類型錯誤的 UnhandledPromiseRejectionWarning

Nodejs 中出現類型錯誤的 UnhandledPromiseRejectionWarning

慕容708150 2023-12-14 14:08:22
當我在nodejs中運行node server.js時,錯誤消息顯示“無法讀取未定義的屬性‘長度’”。我已經安裝了所有相關的庫(例如請求)并查看了不同的相關帖子。然而,問題仍然存在。我認為這與快遞或索引文件有關。有什么建議嗎?非常感謝!(node:14320) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefinedat 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)
查看完整描述

1 回答

?
慕蓋茨4494581

TA貢獻1850條經驗 獲得超11個贊

傳遞undefinedornullapp.use將導致顯示的錯誤。所以我猜測您使用的環境變量有問題,例如:

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

嘗試執行 aconsole.log(process.env.ROUTING_PREFIX)并檢查該值是否已設置或者是否為undefined.


查看完整回答
反對 回復 2023-12-14
  • 1 回答
  • 0 關注
  • 616 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號