I’m trying to use Sentry’s server-side npm package (raven
) with Meteor, and getting the following error when I deploy my app:
Error: Can’t find npm module ‘raven’. Did you forget to call ‘Npm.depends’ in package.js within the ‘modules-runtime’ package?
Why is this happening?
I just booted up an Ubuntu server and cloned my repo and ran meteor --production
and everything runs just fine. This only seems to happen when I deploy to Galaxy. I also deployed via pm2-meteor
to an Ubuntu server and that failed as well.
Got it. So, here’s how I was including Sentry’s logger:
import { Meteor } from 'meteor/meteor';
import { version } from '/package.json';
let Raven;
export function ravenInit() {
if (!Meteor.isServer) return;
const r = require; // using r shortcut suppresses Raven dependency warnings
Raven = r('raven'); // in this case, stop bitching about "pg" package
Raven.config(Meteor.settings.sentryDsn, {
environment: process.env.NODE_ENV,
release: version,
});
return Raven;
}
Raven was giving me warnings about not installing pg
and its related packages, and it doesn’t necessarily need those. So I learned in another thread that if you alias require
to r
, it will silence warnings while in development. Works great.
However, apparently when deploying to a server, this r()
was causing problems. The strange thing is, it was still recognized as require
since it was complaining about not being able to find a module. But when I changed the code:
Raven = require('raven');
Things deployed just fine. Why did this happen?? It doesn’t make any sense!