-
Notifications
You must be signed in to change notification settings - Fork 534
npm dependencies conflict. TypeError: xml2js.Builder is not a function. #27
Comments
Hi, I don't think that it's a good idea to prepackage dependencies inside the plugin. For same reason I then need to prepackage cordova and ios/android platforms also :) I had to reinvent npm for plugin because cordova doesn't install dependent modules (at least for now). But thanks for noticing that, will think of something, although it's strange that I didn't hit the same issue... |
It is strange that you haven't encountered this before. I imagine it could also have something to do with bugs in the current NPM version. I am on the latest right now, 3.5.2, and it even wouldn't allow me to add xml2js as a separate dependency, giving warnings such as these:
and:
There are open bugs for it, like: npm/npm#9999 and npm/npm#10013. I fixed this by removing all installed modules and reinstalling them again. If prepackaging just the modules you require in the hooks (e.g. mkpath, rimraf and xml2js), (not entire cordova ;-) is not an option, then at least this issue can be found for others how may run into this problem. |
I am using v2.14.7, maybe that's why I didn't hit that. Good that you solved it) |
Samething happens to me... I get Error: Cannot find module 'xml2js' on 'cordova build' |
Understood... will change the way how dependency modules are installed to fix this issue. For now try the following:
|
@luisaccedo Uploaded updated version of the plugin in the repo. Possible, should fix issue with
|
fixed! muchísimas gracias! |
Good :) Released v1.1.2 with the fix. Closing the issue. Please, reopen it, if problem persist. |
Hi,
I ran into a problem with your custom dependency resolve mechanism in the afterPrepareHook. When it is run, it checks for the presence of dependent modules. It doesn't check for versions, however. As it happens, I have the xml2js module installed as a child dependency of another one of your plugins ;-)
Now, since xml2js.Builder is a function available from xml2js > 4.0, I get the following error when preparing my project:
My solution for this problem was to add the latest version of xml2js to my projects package.json, so the latest version is available for the plugin. But perhaps it is possible you could prepackage the dependencies inside the plugin, instead of reinventing npm? :-)
The text was updated successfully, but these errors were encountered: