Cordova-plugin-googlemaps: Error: Cannot find module '../node_modules/xml2js'

Created on 19 Mar 2018  Â·  19Comments  Â·  Source: mapsplugin/cordova-plugin-googlemaps

hey i'm using ionic wrapper , and when i try to remove any plugin from my project it's give me this error

node:43267) UnhandledPromiseRejectionWarning: Error: Cannot find module '../node_modules/xml2js'
    at Function.Module._resolveFilename (module.js:543:15)
    at Function.Module._load (module.js:470:25)
    at Module.require (module.js:593:17)
    at require (internal/module.js:11:18)
    at module.exports (/Volumes/Partion/App/Projects/TucTop Application/TucTopFinal/plugins/cordova-plugin-googlemaps/src/before_plugin_rm.js:7:16)
    at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:188:18)
    at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:164:16)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:132:20
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:816:30)
(node:43267) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:43267) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

when i'm go to mention file src/before_plugin_rm.js i found that the require function get a wrong path for xml2js

var xml2js = require('../node_modules/xml2js');

when i correct the path from above line to this

var xml2js = require('../../../node_modules/xml2js');

the problem solved successfully

confirmed fixed

Most helpful comment

i mentioned the solution above
in plugins/cordova-plugin-googlemaps/src/before_plugin_rm.js replace
var xml2js = require('../node_modules/xml2js');
with
var xml2js = require('../../../node_modules/xml2js');
will solve the problem

All 19 comments

+1 Same problem here.

i mentioned the solution above
in plugins/cordova-plugin-googlemaps/src/before_plugin_rm.js replace
var xml2js = require('../node_modules/xml2js');
with
var xml2js = require('../../../node_modules/xml2js');
will solve the problem

Please tell me how did you install the plugins. Please write all steps how to reproduce this problem 100%.

1- install the google plugins
ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="ANFROID_KEY" --variable API_KEY_FOR_IOS="IOS_KEY"
2- install the ionic npm native library
npm install --save @ionic-native/google-maps
after this when try to remove any other plugin from my ionic native plugins it's give me this error

Thank you, but I can not reproduce your issue.

masashi$ cordova plugin list
com.googlemaps.ios 2.6.0 "Google Maps SDK for iOS"
cordova-android-support-gradle-release 1.2.0 "cordova-android-support-gradle-release"
cordova-plugin-app-event 1.2.1 "Application Events"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googlemaps 2.2.8 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-ms-adal 0.10.1 "ADAL for Cordova"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-sqlite-storage 2.2.1 "Cordova sqlite storage plugin"
de.appplant.cordova.plugin.local-notification 0.8.5 "LocalNotification"
es6-promise-plugin 4.2.2 "Promise"
phonegap-plugin-barcodescanner 7.1.0 "BarcodeScanner"
wifiwizard2 2.1.0 "WifiWizard2"

masashi$ cordova plugin rm cordova-plugin-geolocation
Uninstalling cordova-plugin-geolocation from ios
Removing "cordova-plugin-geolocation"
Removing plugin cordova-plugin-geolocation from config.xml file...
Removing cordova-plugin-geolocation from package.json

masashi-macgms:ionic-3-sample masashi$ cordova plugin rm cordova-plugin-googlemaps
Uninstalling 1 dependent plugins.
Uninstalling com.googlemaps.ios from ios
Uninstalling cordova-plugin-googlemaps from ios
Removing "cordova-plugin-googlemaps"
Removing plugin cordova-plugin-googlemaps from config.xml file...
Removing cordova-plugin-googlemaps from package.json

masashi$ 

screen shot 2018-03-19 at 1 15 19 pm

I also tried ionic cordova plugin rm cordova-plugin-googlemaps, but can not reproduced.

masashi$ ionic cordova plugin rm cordova-plugin-googlemaps
> cordova plugin remove cordova-plugin-googlemaps --save
✔ Running command - done!
Uninstalling 1 dependent plugins.
Uninstalling com.googlemaps.ios from ios
Uninstalling cordova-plugin-googlemaps from ios
Removing "cordova-plugin-googlemaps"
Removing plugin cordova-plugin-googlemaps from config.xml file...
Removing cordova-plugin-googlemaps from package.json

masashi$ 

node_modules dose not exist in my situation , i dont know why ,
screen shot 2018-03-19 at 10 22 24 pm

Could you put all files including node_modules on to Github?

And could you tell me your environment? Such as OS, what tool do you use...etc.

this is my ionic info output

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.5
Cordova Platforms  : android 7.0.0
Ionic Framework    : ionic-angular 3.9.2

System:

ios-deploy : 1.9.2 
ios-sim    : 6.1.2 
Node       : v9.8.0
npm        : 5.7.1 
OS         : macOS Sierra
Xcode      : Xcode 9.2 Build version 9C40b

and this is my all plugins in project

com.googlemaps.ios 2.6.0 "Google Maps SDK for iOS"
cordova-plugin-accountkit 1.4.0 "Cordova AccountKit"
cordova-plugin-camera 4.0.2 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-googlemaps 2.2.8 "cordova-plugin-googlemaps"
cordova-plugin-googleplus 5.2.1 "Google SignIn"
cordova-plugin-inappbrowser 2.0.2 "InAppBrowser"
cordova-plugin-market 1.2.0 "Market"
cordova-plugin-request-location-accuracy 2.2.2 "Request Location Accuracy"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-whitelist 1.3.1 "Whitelist"
cordova.plugins.diagnostic 4.0.3 "Diagnostic"
ionic-plugin-deeplinks 1.0.15 "Ionic Deeplink Plugin"
ionic-plugin-keyboard 2.2.1 "Keyboard"
mx.ferreyra.callnumber 0.0.2 "Cordova Call Number Plugin"
onesignal-cordova-plugin 2.3.2 "OneSignal Push Notifications"

Thank you for sharing the information. It seems this cause depends on ionic version.

Okay, I fixed the problem. Please try the multiple_maps branch version.

$> cordova plugin add https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps --variable API_KEY_FOR_ANDROID="..."

i'm very sorry for late replay , i will try the multiple_maps and give you a feedback

Did you test?

I ran into the same problem.
not sure if it's an other issue but using the multiple_maps branch by @wf9a5m75 I got the following error.
I reverted back to simple and old cordova plugin add cordova-plugin-googlemaps --variable … + manually change the src before_plugin_rm.js.

Installing "cordova-plugin-googlemaps" for android
Subproject Path: CordovaLib

            Official document
            https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.0.0/README.md

Installing "cordova-plugin-googlemaps" for ios
Dependent plugin "com.googlemaps.ios" already installed on ios.
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-googlemaps': Error
    at install (/Users/zwacky/data/jw-webapp/mobile/platforms/ios/cordova/lib/plugman/pluginHandlers.js:61:23)
    at ActionStack.process (/Users/zwacky/data/jw-webapp/mobile/platforms/ios/cordova/node_modules/cordova-common/src/ActionStack.js:56:25)
    at PluginManager.doOperation (/Users/zwacky/data/jw-webapp/mobile/platforms/ios/cordova/node_modules/cordova-common/src/PluginManager.js:114:20)
    at PluginManager.addPlugin (/Users/zwacky/data/jw-webapp/mobile/platforms/ios/cordova/node_modules/cordova-common/src/PluginManager.js:144:17)
    at Api.addPlugin (/Users/zwacky/data/jw-webapp/mobile/platforms/ios/cordova/Api.js:234:10)
    at handleInstall (/Users/zwacky/data/jw-webapp/mobile/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:594:10)
    at /Users/zwacky/data/jw-webapp/mobile/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:357:28
    at _fulfilled (/Users/zwacky/data/jw-webapp/mobile/node_modules/cordova/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/Users/zwacky/data/jw-webapp/mobile/node_modules/cordova/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/Users/zwacky/data/jw-webapp/mobile/node_modules/cordova/node_modules/q/q.js:749:13)
Error: Uh oh!
Cannot find resource file "/Users/zwacky/data/jw-webapp/mobile/plugins/cordova-plugin-googlemaps/src/ios/strings/pgm_Localizable_da.json" for plugin cordova-plugin-googlemaps in iOS platform

Could you explain what change did you need?

in case you mean about my change: I followed this https://github.com/mapsplugin/cordova-plugin-googlemaps/issues/2158#issuecomment-374185322

thanks @YousefRabieKhalil
installed after edit
plugins/cordova-plugin-googlemaps/src/before_plugin_rm.js and
plugins/cordova-plugin-googlemaps/src/before_plugin_install.js

Was this page helpful?
0 / 5 - 0 ratings