I'm trying to use a npm package from Meteor.js (Release 0.6.6.3) using Meteor.require
. However it throws an error saying that require
is not defined. Why is this and how can we solve it?
mrt add npm
npm install github
packages.json
{
"github": "0.1.8"
}
github.js
var GITHUB = Meteor.require('github');
Error
ReferenceError: require is not defined
The npm package has lines such as
var https = require('https')
var url = require('url')
var crypto = require('crypto')
Must the package's code be manually edited to use Npm.require
? Editing them manually got rid of the errors.
However theres a line:
module.exports = SOMETHING
How should we call module
from within meteor?
Meteor.require
is a function added by the meteor npm smart package, which actually doesn't do much for using npm other than wrapping some asynchronous callbacks. It's a few months old, so you might want to try using Meteor's Npm.require
directly in case something broke.
The monkey-patching of the Meteor
global by this package is misleading.