TypeError: 'undefined' is not an object only when building

I have some code that I am trying to get working to show a map and where you are and places close by and other things like that. However, it works fine when I test it out using localhost, but when trying to build the app using package, production, or testing, I receive the error:

It seems like something is wrong with the "navigator.geolocation.getCurrentPosition" line or the useCurrentLocation line, because when I comment that line out, everything is fine. Or, if I leave the line uncommented, and change useCurrentLocation to true, it also builds okay. Either way, the application does not output an errors in Google Chrome's console when running.

I think I didn't require the map view because it was included in the views: [ ] in the app.js file. Also, using the listener to add the map view was just something that I was trying differently to get it to work. I was wondering why you could add the view using a button okay but not using a listener. Doing it normally with the items config still doesn't work.

Had same error

after that type error do you get a stack trace and then another error like this?

Code:

[ERROR] Failed loading your application from: <url>

the first error distracted me from the bottom url error. I entered the url into my browser and I got a javascript error in the console and that's the problem that really needed solving. I was testing up until then with foo.com/?foo=bar but the error was citing just foo.com. It had been a while since I tested without the query param and didn't realize I had an error in there. Hopefully your problem is as simple as mine.