Cannot find module 'underscore' from inside npm dependency


#1

Hey y’all :sunflower:

I get this error when building a Meteor 1.4.2 app with a custom Meteor package, which depends on the npm module html-to-text:

Npm.depends({
  'html-to-text': '2.1.3'
});

On build:

W20161116-12:53:47.977(-5)? (STDERR) /Users/Johan/.meteor/packages/meteor-tool/.1.4.2_1.qdgwv6++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
W20161116-12:53:47.977(-5)? (STDERR) 					throw(ex);
W20161116-12:53:47.978(-5)? (STDERR) 					^
W20161116-12:53:47.978(-5)? (STDERR)
W20161116-12:53:47.978(-5)? (STDERR) Error: Cannot find module 'underscore'
W20161116-12:53:47.979(-5)? (STDERR)     at Function.Module._resolveFilename (module.js:325:15)
W20161116-12:53:47.980(-5)? (STDERR)     at Function.Module._load (module.js:276:25)
W20161116-12:53:47.980(-5)? (STDERR)     at Module.require (module.js:353:17)
W20161116-12:53:47.981(-5)? (STDERR)     at require (internal/module.js:12:17)
W20161116-12:53:47.981(-5)? (STDERR)     at Object.<anonymous> (/Users/Johan/.meteor/packages/lookback_emails/.0.7.6.1q437in++os+web.browser+web.cordova/npm/node_modules1/html-to-text/lib/html-to-text.js:4:9)
W20161116-12:53:47.982(-5)? (STDERR)     at Module._compile (module.js:409:26)

It comes from within my html-to-text dependency:

$ head -n 5 /Users/Johan/.meteor/packages/lookback_emails/.0.7.6.1q437in++os+web.browser+web.cordova/npm/node_modules1/html-to-text/lib/html-to-text.js
var fs = require('fs');
var util = require('util');

var _ = require('underscore');
var _s = require('underscore.string');

Nothing fishy there. Is Meteor doing something funny when parsing this? I heard from @tmeasday that Meteor build tool is parsing all require calls in packages/npm modules.


#2

+Plus 1 for getting some feedback on this one. It is actually the most popular email-package out there for meteor, so it would be great if we could solve this.

Anyone looking at this, check out the original github issue with some more details: https://github.com/lookback/meteor-emails/issues/80