Javascript 由于模块加载顺序,Mean.js架构错误

Javascript 由于模块加载顺序,Mean.js架构错误,javascript,mean-stack,meanjs,Javascript,Mean Stack,Meanjs,我正在学习平均堆栈,我还是个新手。我在Mean.io中构建了一个小应用程序,我正试图将它转移到Mean.js,因为该平台似乎更易于维护 事情进展顺利,但我遇到了障碍,我需要一些洞察力 我的核心自定义模块包含了我应用程序的大部分功能,它依赖于Mean.js包含的用户模块来扩展用户的Express模式,这样我就可以在MongoDB的用户文档中存储应用程序所需的自定义数据(首选项、一些记录等),但我遇到了麻烦。当我尝试运行grunt时,应用程序崩溃,并出现以下错误: /Users/myuser/Pro

我正在学习平均堆栈,我还是个新手。我在Mean.io中构建了一个小应用程序,我正试图将它转移到Mean.js,因为该平台似乎更易于维护

事情进展顺利,但我遇到了障碍,我需要一些洞察力

我的核心自定义模块包含了我应用程序的大部分功能,它依赖于Mean.js包含的用户模块来扩展用户的Express模式,这样我就可以在MongoDB的用户文档中存储应用程序所需的自定义数据(首选项、一些记录等),但我遇到了麻烦。当我尝试运行grunt时,应用程序崩溃,并出现以下错误:

/Users/myuser/Projects/pomapp2/node_modules/mongoose/lib/index.js:335
      throw new mongoose.Error.MissingSchemaError(name);
      ^
MissingSchemaError: Schema hasn't been registered for model "User".
Use mongoose.model(name, schema)
    at Mongoose.model (/Users/myuser/Projects/pomapp2/node_modules/mongoose/lib/index.js:335:13)
    at Object.<anonymous> (/Users/myuser/Projects/pomapp2/modules/pom-app/server/models/pomData.server.model.js:5:21)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at /Users/myuser/Projects/pomapp2/config/lib/mongoose.js:15:5
    at Array.forEach (native)
    at Object.module.exports.loadModels (/Users/myuser/Projects/pomapp2/config/lib/mongoose.js:14:30)
    at Object.<anonymous> (/Users/myuser/Projects/pomapp2/config/lib/app.js:20:10)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/myuser/Projects/pomapp2/server.js:6:11)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
[nodemon] app crashed - waiting for file changes before starting...
/Users/myuser/Projects/pomapp2/node\u modules/mongoose/lib/index.js:335
抛出新mongoose.Error.MissingSchemaError(名称);
^
MissingSchemaError:尚未为模型“用户”注册架构。
使用mongoose.model(名称、模式)
在Mongoose.model(/Users/myuser/Projects/pomapp2/node_modules/Mongoose/lib/index.js:335:13)
反对。(/Users/myuser/Projects/pomapp2/modules/pom-app/server/models/pomData.server.model.js:5:21)
在模块处编译(Module.js:409:26)
在Object.Module.\u extensions..js(Module.js:416:10)
在Module.load(Module.js:343:32)
在Function.Module.\u加载(Module.js:300:12)
at Module.require(Module.js:353:17)
根据需要(内部/module.js:12:17)
在/Users/myuser/Projects/pomapp2/config/lib/mongoose.js:15:5
at Array.forEach(本机)
在Object.module.exports.loadModels(/Users/myuser/Projects/pomapp2/config/lib/mongoose.js:14:30)
反对。(/Users/myuser/Projects/pomapp2/config/lib/app.js:20:10)
在模块处编译(Module.js:409:26)
在Object.Module.\u extensions..js(Module.js:416:10)
在Module.load(Module.js:343:32)
在Function.Module.\u加载(Module.js:300:12)
at Module.require(Module.js:353:17)
根据需要(内部/module.js:12:17)
反对。(/Users/myuser/Projects/pomapp2/server.js:6:11)
在模块处编译(Module.js:409:26)
在Object.Module.\u extensions..js(Module.js:416:10)
在Module.load(Module.js:343:32)
[nodemon]应用程序崩溃-正在等待文件更改,然后再启动。。。
在我看来,这是模块文件夹中的模块按字母顺序加载的结果。我的模块名为“pom-app”,所以在“users”之前加载,所以还没有可扩展的模式,一切都崩溃了

如果我将核心模块文件夹重命名为z-pom-app,使其最后加载,grunt将成功启动Mean.js应用程序。我的模块中的一些功能被破坏了,因为Angular仍然注册我的模块名而不使用z,从而导致对旧路径中的文件的请求,但我认为这可以通过简单地重命名Angular模块来修复。然而,重要的是Mean.js核心运行,Express模块扩展代码现在可以工作了,注册的新用户完全按照我的预期将我的附加字段添加到他们的用户文档中,就像他们在我最初运行的Mean.io应用程序中所做的那样

所以要解决这个问题。。。我不愿意将我的模块重命名为z-pom-app,因为这看起来真的很粗糙(我不希望在URL中出现这种情况),而且必须有一种干净的方法来做到这一点。我错过了什么?如何在模块加载之前加载用户模块?还是因为我是一个新手,所以我完全错了,在这种情况下,我应该如何改变我的应用程序的结构

正如我所说,我是新来的,所以如果你认为我缺少一些基本的东西,这是很有可能的


我非常感谢您在这里提供的任何帮助或想法,谢谢

想知道我是否可以让我的模块依赖于用户模块?