Can't require lodash anymore - returns undefined


#1

Very weird error out of nowhere …

in my imports/startup/server/index.js I used to do

const lodash = require('lodash');
// override _ on server
_ = lodash;

But if I log _ or lodash now both return undefined … wtf is going on?
In my meteor shell I can require and everything works just fine but with no apparent reason I can’t require in my startup file anymore. any ideas?

42

Can anyone explain this to me?


#2

I’m getting same error for underscore.js


#3

It seems to me Meteor 1.6 release somehow broke overriding _ on the server. Only solution I found so far is using import * as _ from 'lodash' in every server file I am using lodash in.
On the client _ = require('lodash') still works just fine.

I am confused …


#4

Can anyone (maybe of the MDG staff) clarify this? I really don’t understand why this suddenly stopped working …
I can not overwrite _ anymore and also can not define a “server wide global” var anymore (such as _ = lodash) - did the var scope on the server change with v1.6?


Lodash (_) being overwritten with undefined in 1.6?