Meteor cannot find module "module"

I am trying to install a Spooky module in a meteor (this one is in my shared folder: app / public / node_modules).

I read the answers in this post and added the following code in server / server.js

Meteor.startup ->
    path = Npm.require 'path'
    fs = Npm.require 'fs'
    base = path.resolve '.'
    isBundle = fs.existsSync base + '/bundle'
    modulePath = base + (if isBundle then '/bundle/static' else '/public') + '/node_modules'
    spooky = Npm.require modulePath + '/spooky'

But when I launch a meteorite, I get:

Error: Cannot find module '/Users/mac/Documents/websites/app/.meteor/local/build/programs/server/public/node_modules/spooky'
+3
source share
2 answers

You need to create a smart package to use Npm modules in your application. Alternatively, you can use meteor-npm.

You cannot use it Npm.requireyourself for non-standard npm modules such as spooky.

If you are using meteor-npm, you can install it with a meteorite: mrt add npm

Meteor.require("spooky") , , . json. : http://meteorhacks.com/complete-npm-integration-for-meteor.html.

- -, npm. : https://github.com/avital/meteor-xml2js-npm-demo

xml2js npm, , .

/packages (, spooky) meteor meteor add spooky.

weather.meteor.com , (, (https://atmosphere.meteor.com/package/stripe)).

+1

​​ Akshat :

cd project
meteor add meteorhacks:npm

project/packages.json:

{
  "redis": "0.8.2",
  "github": "0.1.8"
}

npm:

var Github = Meteor.npmRequire('github');
var github = new Github();

github.gists.getFromUser({user: 'arunoda'}, function(err, gists) {
  console.log(gists);
});
0

All Articles