Constants.manifest.packagerOpts.dev is undefined


#1

Someone on the general chat recommended using this for detecting local environment debugging only. But it appears to not be available when the app is published to Expo.

I would think a manifest should never delete properties it isn’t using, it should redefine them as false.


#2

Hi @ericjames - I’m not quite sure I understand what the issue is here. If packagerOpts.dev is undefined then that means the app is running in prod/published mode. Could you explain what you were expecting to see and what you’re trying to achieve?


#3

What I was actually doing was not wanting to send Google Analytics events if I was running in local environment mode. So I was looking for a constant variable that Expo could tell me if we were in DEV vs the actual app (like PROD).

That behavior is fine, would I simply look for the existence of packagerOpts?

A side note, the docs are often not informative enough or at least not clear what everything is/doing. Maybe the authors should provide a link to the original issue or discussion in Github.


#4

@ericjames the packagerOpts key will exist if your app is being served locally from a packager server (rather than using pre-bundled JS). You could do something like let isDev = packagerOpts && packagerOpts.dev which should handle all cases and tell you what you want.

Our docs are always a work in progress – if there are any specific changes or improvements you would like to see you are welcome to send us a PR!


closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.