【问题标题】:Meteor: Cannot read property 'config' of undefined流星:无法读取未定义的属性“配置”
【发布时间】:2016-10-16 16:40:22
【问题描述】:

我正在尝试在移动 angular-meteor 应用中实现 accounts-ui。我已经安装了所有依赖项,我正在尝试使用以下代码设置 Accounts.ui.config:

   import { Accounts } from 'meteor/accounts-base';

   Accounts.ui.config({
     passwordSignupFields: 'USERNAME_AND_EMAIL'
   });

但是当我尝试运行应用程序时,我收到以下错误:

TypeError: Cannot read property 'config' of undefined
    at meteorInstall.server.auth.js (server/auth.js:4:1)
    at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
    at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
    at server/publications.js:124:1
    at /home/ubuntu/workspace/musiker/.meteor/local/build/programs/server/boot.js:297:10
    at Array.forEach (native)
    at Function._.each._.forEach (/home/ubuntu/.meteor/packages/meteor-   tool/.1.4.0.hylsrj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
    at /home/ubuntu/workspace/musiker/.meteor/local/build/programs/server/boot.js:133:5

我想也许我需要为页面导入帐户 UI,但 docs 清楚地显示了导入帐户库。我也尝试过导入 accouns-ui,但仍然遇到同样的错误。

谢谢!

-埃里克

【问题讨论】:

  • 你使用什么包?是否添加了包 account-password 和 accounts-ui?
  • 我有所有正确的包,我只是想在服务器上设置配置,需要在客户端上设置。

标签: meteor meteor-accounts


【解决方案1】:

使用前添加accounts包。

在项目根目录下使用该命令添加包
meteor add accounts-ui accounts-password

这应该使您的代码工作。

【讨论】:

    【解决方案2】:

    您需要在客户端代码中添加配置:

    import { Accounts } from 'meteor/accounts-base';
    
    Accounts.ui.config({
      passwordSignupFields: 'USERNAME_ONLY',
    });
    

    查看here了解更多详情。

    【讨论】:

      【解决方案3】:

      您似乎正在尝试在服务器上执行Accounts.ui.config,但此功能仅在客户端可用。

      【讨论】:

        【解决方案4】:

        它是 Accounts.config。

           Accounts.config({
             passwordSignupFields: 'USERNAME_AND_EMAIL'
           });
        

        【讨论】:

          【解决方案5】:

          我有同样的错误。 首先,我将 JS 放入 lib/startup/accounts-config.js 或 lib/accounts-config.js ,它仍然有错误。 但是当我将JS放入imports/startup/accounts-config.js中时,它变得有效。不知道是什么原因。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2022-07-06
            • 1970-01-01
            • 1970-01-01
            • 2022-07-12
            • 1970-01-01
            • 1970-01-01
            • 2022-01-15
            相关资源
            最近更新 更多