我遵循
github meteorirc项目的领导,把它们放在/ public /
我通过npm从/ public /中安装了我的节点模块,因此我有一个/ public / node_modules /目录.
我不认为这是他们的“正确”或“标准”的地方,因为根据流星文件…
Meteor gathers all your JavaScript files,excluding anything under the
client and public subdirectories,and loads them into a Node.js server
instance inside a fiber
- var require = __meteor_bootstrap__.require;
- var path = require("path");
- var fs = require('fs');
- var base = path.resolve('.');
- if (base == '/'){
- base = path.dirname(global.require.main.filename);
- }
- var Twit;
- var twitPath = 'node_modules/twit';
- var publicTwitPath = path.resolve(base+'/public/'+twitPath);
- var staticTwitPath = path.resolve(base+'/static/'+twitPath);
- if (path.existsSync(publicTwitPath)){
- Twit = require(publicTwitPath);
- }
- else if (path.existsSync(staticTwitPath)){
- Twit = require(staticTwitPath);
- }
- else{
- console.log('WARNING Twit not loaded. Node_modules not found');
- }
根据文档,这不是标准的,我不相信我应该这样做.然而,它在我的开发平台和部署meteor.com的生产中起作用.
在项目的目录结构中,应该安装节点模块,以便它们在本地工作,并在meteor.com或其他地方部署?
解决方法
- cd /usr/local/meteor/lib/ && npm install <module>