Meteor:ReferenceError:帐户未定义

2024-01-20

我刚刚完成了 Meteor 包的开发。现在我想通过将其添加到新的 Meteor 应用程序来测试它:

my_cool_package_name/package.js

Package.on_use(function(api){
    api.use("[email protected] /cdn-cgi/l/email-protection");
});

将 my_cool_package_name 添加到新项目

meteor add my_cool_package_name

Changes to your project's package version selections:

    accounts-base          added, version 1.2.0
    accounts-password      added, version 1.1.1

列出已安装的软件包

meteor list

    meteor-platform      1.2.2  Include a standard set of Meteor packages in your app
    my_cool_package_name  1.0.0+ This is my_cool_package_name

启动流星

meteor

ReferenceError: Accounts is not defined

W20150817-15:30:49.707(-4)? (STDERR)     at manage_users_log.insert.username (app/server/fixtures.js:7:17)
W20150817-15:30:49.707(-4)? (STDERR)     at Array.forEach (native)
W20150817-15:30:49.707(-4)? (STDERR)     at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
W20150817-15:30:49.708(-4)? (STDERR)     at app/server/fixtures.js:6:4
W20150817-15:30:49.708(-4)? (STDERR)     at app/server/fixtures.js:36:3
W20150817-15:30:49.708(-4)? (STDERR)     at /Users/me/Documents/meteor/my_app/.meteor/local/build/programs/server/boot.js:222:10
W20150817-15:30:49.708(-4)? (STDERR)     at Array.forEach (native)
W20150817-15:30:49.708(-4)? (STDERR)     at Function._.each._.forEach (/Users/me/.meteor/packages/meteor-tool/.1.1.4.1kp2n64++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150817-15:30:49.708(-4)? (STDERR)     at /Users/me/Documents/meteor/my_app/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.

服务器/fixtures.js

if (Meteor.users.find().count() === 0) {
    var users = [
        {username:'admin',email:'[email protected] /cdn-cgi/l/email-protection',password:'adminadmin',roles:['admin'],status:'enabled',profile:{first_name:'admin',last_name:'admin'}},
        {username:'user',email:'[email protected] /cdn-cgi/l/email-protection',password:'useruser',roles:['user'],status:'enabled',profile:{first_name:'user',last_name:'user'}}
    ];
    _.each(users, function(user){
        var user_id = Accounts.createUser({
            username: user.username,
            email: user.email,
            password: user.password,
            profile: {
                first_name: user.profile.first_name,
                last_name: user.profile.last_name,
            }
        });
        Meteor.users.update(
            {_id: user_id},
            {$set: 
                {
                    roles: user.roles,
                    status: user.status
                }
            }
        );
    });
}

if (manage_users_log.find().count() === 0) {
    manage_users_log.insert({
        username: "admin",
        category: "server_startup",
        description: "Meteor server started."
    });
}

如果有帮助的话,应用程序结构的布局如下:

client
    my_app.html
packages
    my_cool_package_name
server
    fixtures.js

Use api.imply使您的应用程序能够访问包依赖项的导出符号。

Package.onUse(function(api){
  api.use("accounts-pas[email protected] /cdn-cgi/l/email-protection");
  //
  api.imply("[email protected] /cdn-cgi/l/email-protection");
});

当您添加依赖于其他包的包时,它们导出的符号对主应用程序不可用,您需要暗示它们才能实现这一点。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Meteor:ReferenceError:帐户未定义 的相关文章

随机推荐