尝试创建一个帐户并获取错误消息

时间:2019-05-23 16:15:33

标签: javascript node.js express express-handlebars

运行code并尝试注册时,我收到一系列错误消息:

(node:16084) UnhandledPromiseRejectionWarning: ValidationError: User validation failed: password: Path `password` is required.
    at new ValidationError (D:\JavaScript\TowerDefense\NewTowerDefense\TowerDefense-JS\node_modules\mongoose\lib\error\validation.js:30:11)
    at model.Document.invalidate (D:\JavaScript\TowerDefense\NewTowerDefense\TowerDefense-JS\node_modules\mongoose\lib\document.js:2259:32)
    at p.doValidate.skipSchemaValidators (D:\JavaScript\TowerDefense\NewTowerDefense\TowerDefense-JS\node_modules\mongoose\lib\document.js:2108:17)
    at D:\JavaScript\TowerDefense\NewTowerDefense\TowerDefense-JS\node_modules\mongoose\lib\schematype.js:981:9
    at process._tickCallback (internal/process/next_tick.js:61:11) (node:16084) 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(). (rejection id: 1) (node:16084) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. POST /users/authRegister -
- ms - -

我不知道我做错了什么,一次又一次,因为我不知道哪个文件导致了问题,因此我将整个回购信息发布到这里。

编辑

仔细检查Mongo连接字符串后,除了最近的错误消息外,我现在还得到了它:

(node:7964) 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(). (rejection id: 1)

(node:7964) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:7964) UnhandledPromiseRejectionWarning: ReferenceError: error is not defined

    at User.findOne.then.user (D:\JavaScript\TowerDefense\NewTowerDefense\TowerDefense-JS\public\javascripts\userHandler.js:53:13)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:7964) 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(). (rejection id: 2)

0 个答案:

没有答案