AuserID is associated with a connection - if you’re trying to find out the userID in a startup block, at init time, or in a defer, timeout or interval (amongst others depending on things like REST APIs, cron jobs, etc) it wont work.
I can call this anywhere. Meteor.functions.getCurrentUserId will return current user’s id.
I have a few calling this inside meteor methods and I also use react.js so inside of the components.
You’re saying you get an error, I’m asking where is the root location you call this from that you get an error. Because, exactly as the error says, you can only call this on the server inside a method or publication.
Are you getting an error when you call that from a method or publication, or are you trying to call it from somewhere else (like the terminal) where it would have no way of knowing what the user id is and therefore correctly throws an error.