Ionic2 installer spoiled?

Today I have started another project based on your tutorial. Typically I ran “ionic start TestProject --v2 --ts” then “ionic serve”. Chrome browser started, nothing appears. In the developer console error message appeared

"googlemaps.js:15 Uncaught ReferenceError: plugin is not defined". Then I have inspected project code and commented out "exports.GoogleMapsEvent = {
    MAP_READY: plugin.google.maps.event.MAP_READY,
    MAP_CLICK: plugin.google.maps.event.MAP_CLICK,
    MAP_LONG_CLICK: plugin.google.maps.event.MAP_LONG_CLICK,
    MY_LOCATION_BUTTON_CLICK: plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK,
    CAMERA_CHANGE: plugin.google.maps.event.CAMERA_CHANGE,
    CAMERA_IDLE: plugin.google.maps.event.CAMERA_IDLE,
    MAP_LOADED: plugin.google.maps.event.MAP_LOADED,
    MAP_WILL_MOVE: plugin.google.maps.event.MAP_WILL_MOVE,
    MAP_CLOSE: plugin.google.maps.event.MAP_CLOSE,
    MARKER_CLICK: plugin.google.maps.event.MARKER_CLICK,
    INFO_CLICK: plugin.google.maps.event.INFO_CLICK,
    MARKER_DRAG: plugin.google.maps.event.MARKER_DRAG,
    MARKER_DRAG_START: plugin.google.maps.event.MARKER_DRAG_START,
    MARKER_DRAG_END: plugin.google.maps.event.MARKER_DRAG_END,
    OVERLAY_CLICK: plugin.google.maps.event.OVERLAY_CLICK
};"

After that Chrome refreshed and the project started as usual.

1 Like

I am also encountering this error, after trying to resolve the latest typings compatibility.

ionic serve --lab

Uncaught ReferenceError: plugin is not defined  googlemaps.js:15s
Uncaught ReferenceError: ionic is not defined ?ionicplatform=ios:61

It was working when I started this morning… :unamused:

+1 Same problem here

temporary fix if you are not using google maps.
Replace original lines with:

var plugin = require(’./plugin’);
var plugin_1 = require(’./plugin’);
var Rx_1 = require(‘rxjs/Rx’);
var plugin_2 = require(’./plugin’);
/**

  • You can listen to these events where appropriate
    */
    // exports.GoogleMapsEvent = {
    // MAP_READY: plugin.google.maps.event.MAP_READY,
    // MAP_CLICK: plugin.google.maps.event.MAP_CLICK,
    // MAP_LONG_CLICK: plugin.google.maps.event.MAP_LONG_CLICK,
    // MY_LOCATION_BUTTON_CLICK: plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK,
    // CAMERA_CHANGE: plugin.google.maps.event.CAMERA_CHANGE,
    // CAMERA_IDLE: plugin.google.maps.event.CAMERA_IDLE,
    // MAP_LOADED: plugin.google.maps.event.MAP_LOADED,
    // MAP_WILL_MOVE: plugin.google.maps.event.MAP_WILL_MOVE,
    // MAP_CLOSE: plugin.google.maps.event.MAP_CLOSE,
    // MARKER_CLICK: plugin.google.maps.event.MARKER_CLICK,
    // INFO_CLICK: plugin.google.maps.event.INFO_CLICK,
    // MARKER_DRAG: plugin.google.maps.event.MARKER_DRAG,
    // MARKER_DRAG_START: plugin.google.maps.event.MARKER_DRAG_START,
    // MARKER_DRAG_END: plugin.google.maps.event.MARKER_DRAG_END,
    // OVERLAY_CLICK: plugin.google.maps.event.OVERLAY_CLICK
    // };

but this are generated by framework in app.bundle.js file

that temporary fix works, this is a framework problem. With that we are unable to deploy to device or something else. :s

Try to comment out these lines of code I have mentioned. For me that worked.

It works, but makes the ionic serve tool useless since I have to manually comment after each build. Anyone have any insight to what changed?

It seems that the problem is caused by the latest updates to ionic-native.

There’s an open issue about it - I would recommend you to vote/comment there.

As a workaround an older version of ionic-native could be used, as mentioned by @jorgercosta:

If one doesn’t want to downgrade and doesn’t necessarily need google maps functionality then one can comment out relevant section of code in googlemaps.js. In that case the code which was reproduced to app.bundle.js would be commented out too and in turn the error wouldn’t reproduce. Am I right?

// exports.GoogleMapsEvent = {
// MAP_READY: plugin.google.maps.event.MAP_READY,
// MAP_CLICK: plugin.google.maps.event.MAP_CLICK,
// MAP_LONG_CLICK: plugin.google.maps.event.MAP_LONG_CLICK,
// MY_LOCATION_BUTTON_CLICK: plugin.google.maps.event.MY_LOCATION_BUTTON_CLICK,
// CAMERA_CHANGE: plugin.google.maps.event.CAMERA_CHANGE,
// CAMERA_IDLE: plugin.google.maps.event.CAMERA_IDLE,
// MAP_LOADED: plugin.google.maps.event.MAP_LOADED,
// MAP_WILL_MOVE: plugin.google.maps.event.MAP_WILL_MOVE,
// MAP_CLOSE: plugin.google.maps.event.MAP_CLOSE,
// MARKER_CLICK: plugin.google.maps.event.MARKER_CLICK,
// INFO_CLICK: plugin.google.maps.event.INFO_CLICK,
// MARKER_DRAG: plugin.google.maps.event.MARKER_DRAG,
// MARKER_DRAG_START: plugin.google.maps.event.MARKER_DRAG_START,
// MARKER_DRAG_END: plugin.google.maps.event.MARKER_DRAG_END,
// OVERLAY_CLICK: plugin.google.maps.event.OVERLAY_CLICK
// };

This should be fixed in the latest release of ionic-native, 1.2.4.

Sorry about any issue!

You should update the version in your package.json

You’re right it works. Thank you!

1 Like