Reputation: 4751
In Node, you can require local modules using:
var myModule = require('./lib/mymodule.js');
Is it possible to do something similar with Meteor?
Upvotes: 2
Views: 443
Reputation: 22696
Here is a simple example to get you started :
Let's install underscore from npm as a local node module in our app server directory :
cd server
npm install underscore
Then in server/startup.js
type the following code :
var underscoreLatest=Npm.require(process.cwd()+"/app/server/node_modules/underscore/underscore.js");
Meteor.startup(function(){
// will display "1.7.0" as of december 2014
console.log(underscoreLatest.VERSION);
});
So basically you need to use Npm.require
instead of require
and you have to be careful that the Meteor Node.JS process current working directory is NOT the root of your Meteor project directory, but is instead ".meteor/local/build/programs/server"
.
Upvotes: 2