重新包装meteorry for meteor会给出错误" ReferenceError:窗口未定义"

时间:2015-01-21 16:40:16

标签: javascript meteor masonry

我希望将desandro/masonry添加到我的流星项目中。但是没有流星包对我有用,所以想到创建一个。

这是package.js

'use strict';
 var packageName = 'masonryjs:masonry'; 
 Package.describe({
    name: packageName,
    summary: 'Masonryjs. cascading grid layout library',
    version: '1.1.0',
    git: 'https://github.com/desandro/masonry'
});
Package.onUse(function (api) {
    api.versionsFrom(['METEOR@0.9.0', 'METEOR@1.0']);
    api.export('masonry');
    api.addFiles([
        'masonry.pkgd.js',
        'export.js'
    ]);
});

export.js

masonry = this.masonry;
delete this.masonry;

该软件包已添加,但是当我运行我的meteor应用程序时,我收到此错误

W20150121-21:50:29.788(5.5)? (STDERR)/home/nipun/.meteor/packages/meteor-tool/.1.0.40.1d3bp9e++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/服务器-LIB / node_modules /纤维/ future.js:173 W20150121-21:50:29.788(5.5)? (STDERR)throw(ex); W20150121-21:50:29.788(5.5)? (STDERR)^ W20150121-21:50:29.824(5.5)? (STDERR)ReferenceError:未定义窗口 W20150121-21:50:29.824(5.5)?砌体(STDERR)(packages / masonryjs:masonry / masonry.pkgd.js:147:1) W20150121-21:50:29.824(5.5)? (STDERR)/home/nipun/development/web/mason/.meteor/local/build/programs/server/packages/masonryjs_masonry.js:2980:4 W20150121-21:50:29.824(5.5)? (STDERR)/home/nipun/development/web/mason/.meteor/local/build/programs/server/packages/masonryjs_masonry.js:3008:3 W20150121-21:50:29.824(5.5)? (STDERR)/home/nipun/development/web/mason/.meteor/local/build/programs/server/boot.js:205:10 W20150121-21:50:29.825(5.5)? (STDERR)在Array.forEach(本机) W20150121-21:50:29.825(5.5)? (STDERR)在函数。 .each。 .forEach(/home/nipun/.meteor/packages/meteor-tool/.1.0.40.1d3bp9e++os.linux.x86_32+web.browser+ web.cordova /流星刀具os.linux.x86_32 / dev_bundle /服务器-LIB / node_modules /下划线/ underscore.js:79:11) W20150121-21:50:29.825(5.5)? (STDERR)/home/nipun/development/web/mason/.meteor/local/build/programs/server/boot.js:116:5

1 个答案:

答案 0 :(得分:1)

如果您不希望在window不可用的服务器上使用此程序包,则:

api.addFiles([ 'masonry.pkgd.js', 'export.js' ], 'client');
api.export('masonry', 'client');