问题描述
我跟随github meteorirc项目的负责人,并将其放在/public/
I followed the github meteorirc project's lead and put them in /public/
我通过npm从/public/内部安装了节点模块,因此我有一个/public/node_modules/目录.
I installed my node modules via npm from inside /public/ and therefore I have a /public/node_modules/ directory.
根据Meteor文档,我认为这对他们来说不是适当"或标准"的地方...
I don't think this is the 'proper' or 'standard' place for them because according to the Meteor docs...
要加载的代码在服务器目录和服务器js文件中,如下所示.
The code to load is in the server dir and server js files and looks like this.
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的生产环境中使用.
Based on the docs this is not standard and I don't believe I should be doing it this way. Yet, it works both on my dev platform and in production at deploy meteor.com.
应在项目的目录结构中的哪些位置安装节点模块,以便它们在本地运行并在meteor.com或其他位置部署?
Where in the directory structure of the project should node modules be installed so that they work locally and upon deployment at meteor.com or elsewhere?
推荐答案
cd /usr/local/meteor/lib/ && npm install <module>
这篇关于我们将npm安装的节点模块放在流星项目中的什么位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!