【发布时间】:2015-01-22 20:14:41
【问题描述】:
试图找出将 npm 包加载到 Meteor 中的方法。具体来说,我尝试使用future-npm
我试过这样做:
Package.describe({
summary: "Blah blah",
version: '0.0.1'
});
Npm.depends({future: "2.3.1"});
Package.onUse(function (api) {
api.addFiles('lubert.js', 'server');
api.export('Lubert');
});
不幸的是,我收到以下控制台错误
Uncaught ReferenceError: Npm is not defined
我已经阅读了documentation 并且没有加载任何依赖项
我做错了什么?
更新 2:我的 package.js 看起来像
Package.describe({
name: 'trepafi:package',
summary: '',
version: '0.0.3',
git: 'https://github.com/trepafi/meteor-package.git'
});
Npm.depends({
"future": "2.3.1"
});
Package.onUse(function(api) {
api.versionsFrom('1.0');
api.use(['tracker', 'underscore'], ['client']);
api.addFiles(['package.js'], ['client']);
api.export('Package', ['client']);
});
更新 1:我的 package.json 看起来像
{
"name": "trepafi-package",
"version": "0.0.3",
"description": "Package for Meteor",
"repository": {
"type": "git",
"url": "https://github.com/trepafi/meteor-package.git"
},
"author": "Lubert Palacios",
"license": "MIT",
"homepage": "https://github.com/trepafi/meteor-package",
"dependencies": {
"future": "^2.3.1"
}
}
我也尝试过使用 meteorhacks:npm 没有成功。 如果我可以使用“原生”方式就好了
【问题讨论】:
-
你的包文件结构是什么?你的语法对我来说很好。
-
github.com/meteorhacks/npm 这应该可以解决问题
-
@saimeunt 刚刚添加了
-
@Sindis 我已经尝试过了,但没有成功
-
你不需要提供 package.json,只需要一个 package.js 就在它自己的包目录下。