Trying to Use Underscore

I added the underscore package to my Meteor app as follows:

meteor add underscore

Am I missing something because when I use the _ I get these errors:
client/imports/app/root/crm/customers/surveyPre/surveyPre-container.component.ts (159, 25): Cannot find name ‘’.
client/imports/app/root/crm/customers/surveyPre/surveyPre-container.component.ts (163, 25): Cannot find name '
’.

Any help would be appreciated.

Let me add that I am using TS, in a Windows environment.

Can you use _ in the browser console? If not, then it is not getting registered as a global.

Meteor already has a global _ (v1.5.2) in its packages. If you want to add a new version separately, I think it may be conflicting with the older version. In that case you may need to register it as global, or import from ‘meteor/undersocre’. Though if you are adding it separately, I will suggest to use npm and not meteor.

Thanks so much. I have to apologize in advance. I was doing something stupid. So i figured out if I import the ‘_’ on the script then the error goes away on the meteor output.

So here is what I did at the top of the script page.

import { _ } from 'underscore';

Looking good now. @s7dhansh thanks for responding to this request. I really appreciate your help.

1 Like