Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'xml2js' #352

Closed
smithgeek opened this issue Aug 5, 2017 · 7 comments
Closed

Cannot find module 'xml2js' #352

smithgeek opened this issue Aug 5, 2017 · 7 comments

Comments

@smithgeek
Copy link

I'm trying to add this plugin to my cordova project and I'm getting the error "Error: Cannot find module 'xml2js'" when trying to run cordova plugin add branch-cordova-sdk. Working backwards it looks like this started in 2.6.1 and I can successfully install 2.6.0.

Full Error
cordova plugin add branch-cordova-sdk@2.6.1
Fetching plugin "branch-cordova-sdk@2.6.1" via npm
Installing "branch-cordova-sdk" for android
BRANCH SDK: Installing node dependency xml2js
Subproject Path: CordovaLib
Failed to install 'branch-cordova-sdk':Error: Cannot find module 'xml2js'
at Function.Module._resolveFilename (module.js:472:15)
at Function.Module._load (module.js:420:25)
at Module.require (module.js:500:17)
at require (internal/module.js:20:19)
at C:\Projects\CordovaTest\plugins\branch-cordova-sdk\src\scripts\lib\xmlHelper.js:5:16
at Object. (C:\Projects\CordovaTest\plugins\branch-cordova-sdk\src\scripts\lib\xmlHelper.js:49:3)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
at tryModuleLoad (module.js:449:12)
Error: Cannot find module 'xml2js'

@ethanneff
Copy link
Contributor

Hello,

xml2js is one of the dependencies for Branch. Cannot find module 'xml2js' happens whenever you are trying to run multiple Cordova commands at once. This will cause the async calls within the Branch Cordova SDK install process to not finish, and the dependencies to not install.

I would recommend updating the Branch SDK and going through the testing guide to make sure you are running only 1 Cordova command for the initial Branch SDK install.

Thanks,

@smithgeek
Copy link
Author

I tried following the instructions in those 2 links before posting with no luck. Also, as I said this works fine if I go back to version 2.6.0, but anything newer fails.

@ethanneff
Copy link
Contributor

Hello @smithgeek,

Thank you for the quick responses. You are correct. Something broke between 2.6.0 and 2.6.4. I have a feeling it is related to 44a7ac1f which was a response to #333. I will continue to investigate to see if a revert or a workaround is needed for this to be correct. I will reach out as soon as a new version is ready.

Thanks for finding this.

@mackbrowne
Copy link

I did a npm install for these modules by hand, which got rid of these issues. However now my app will not run on android. No issues with ios as far as I can tell.

@ethanneff I tried a few different previous versions, which version would you consider the last 'stable' version for both ios and android?

Best regards,
Mack

@ethanneff
Copy link
Contributor

ethanneff commented Aug 8, 2017

Hello @mackbrowne,

You can target v2.5.17 as a stable build. v2.6.0 added commerce event tracking which is a non-critical feature. In the meantime, I will continue working on a fix.

Thanks,

@mackbrowne
Copy link

thanks @ethanneff !!

@ethanneff
Copy link
Contributor

Hello again,

I apologize for the delay. It appears these issues were related to Cordova. After making the following changes I was able to remove the errors:

npm i -g cordova@7.0.1
cordova platform update android@6.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants