dpa99c / cordova-custom-config

Cordova/Phonegap plugin to update platform configuration files based on preferences and config-file data defined in config.xml
318 stars 84 forks source link

android platform 7.1.1 + cordova 8.1.0 - cordova-custom-config: Error loading dependencies for applyCustomConfig.js #149

Closed Muzietto closed 5 years ago

Muzietto commented 5 years ago

I'm submitting a ... (check one with "x"):

Bug report

Current behavior:

I am upgrading my environment to move beyond cordova 6.x.x.

During an "cordova platform add android --fetch" the execution stops with:

CordovaError: Promise rejected with non-error: 'cordova-custom-config: Error loading dependencies 
for applyCustomConfig.js - ensure the plugin has been installed via cordova-fetch or run \'npm 
install cordova-custom-config\': Cannot find module \'elementtree\''
at cli.catch.err (/home/marco/workspace/eidoo-app/node_modules/cordova/bin/cordova:29:15)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
[15:04:29] 'prepare-cordova' errored after 11 min

The error message clearly states that the issue happens during the run of cordova-custom-config. However I am already running everything with --fetch

I have modified the config.xml file according to https://www.npmjs.com/package/cordova-custom-config#changes-in-cordova-custom-config5

Expected behavior:

The cordova platform add android command runs without interruption.

Environment information

Muzietto commented 5 years ago

Same error on MacOS 10.14. Please comment!

dpa99c commented 5 years ago

This is not happening for me in a test case - see console output below.

If possible, please provide a similar set of reproducible steps which recreates the issue.

console output ``` $ cordova -v 8.1.0 $ node -v v9.2.1 $ sw_vers ProductName: Mac OS X ProductVersion: 10.13.6 BuildVersion: 17G65 $ npm -v 5.6.0 $ cordova create test && cd test Creating a new cordova project. $ cordova plugin add cordova-custom-config Adding cordova-custom-config to package.json Saved plugin info for "cordova-custom-config" to config.xml $ cordova platform add android Using cordova-fetch for cordova-android@~7.1.1 Adding android project... Creating Cordova project for the Android platform: Path: platforms/android Package: io.cordova.hellocordova Name: HelloCordova Activity: MainActivity Android target: android-27 Android project created with cordova-android@7.1.1 Android Studio project detected Android Studio project detected Installing "cordova-custom-config" for android cordova-custom-config: Skipping auto-restore of config file backup(s) Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project Installing "cordova-plugin-whitelist" for android This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in. Adding cordova-plugin-whitelist to package.json Saved plugin info for "cordova-plugin-whitelist" to config.xml --save flag or autosave detected Saving android@~7.1.1 into config.xml file ... $ cordova prepare android cordova-custom-config: Skipping auto-restore of config file backup(s) Android Studio project detected $ cordova platform rm android Removing platform android from config.xml file... Removing android from cordova.platforms array in package.json $ rm -Rf node_modules/ $ cordova platform add android Using cordova-fetch for cordova-android@~7.1.1 Adding android project... Creating Cordova project for the Android platform: Path: platforms/android Package: io.cordova.hellocordova Name: HelloCordova Activity: MainActivity Android target: android-27 Android project created with cordova-android@7.1.1 Android Studio project detected Android Studio project detected Installing "cordova-custom-config" for android Installing "cordova-plugin-whitelist" for android This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in. cordova-custom-config: Skipping auto-restore of config file backup(s) --save flag or autosave detected Saving android@~7.1.1 into config.xml file ... $ cordova prepare android cordova-custom-config: Skipping auto-restore of config file backup(s) Android Studio project detected $ rm -Rf plugins/ node_modules/ platforms/ $ cordova platform add android Using cordova-fetch for cordova-android@^7.1.1 Adding android project... Creating Cordova project for the Android platform: Path: platforms/android Package: io.cordova.hellocordova Name: HelloCordova Activity: MainActivity Android target: android-27 Android project created with cordova-android@7.1.1 Android Studio project detected Android Studio project detected Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project Installing "cordova-plugin-whitelist" for android This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in. Adding cordova-plugin-whitelist to package.json Saved plugin info for "cordova-plugin-whitelist" to config.xml Discovered plugin "cordova-custom-config" in config.xml. Adding it to the project Installing "cordova-custom-config" for android Adding cordova-custom-config to package.json Saved plugin info for "cordova-custom-config" to config.xml --save flag or autosave detected Saving android@~7.1.1 into config.xml file ... $ cordova prepare android cordova-custom-config: Skipping auto-restore of config file backup(s) Android Studio project detected ```
Muzietto commented 5 years ago

All wrongs happen during a cordova platform add ios --fetch operation, starting from a pretty large config.xml file.

Done some more experimentation. I am actually able to run the computation further by installing manually npm packages each time the installation of cordova-custom-config throws (same message as in my first note, with only the package name changed).

So far I've installed:

I see some of them are explicitly mentioned inside applyCustomConfig.js; others could be dependencies of the earlier ones. Any idea?

dpa99c commented 5 years ago

Some of these are direct dependencies of this plugin and others I would assume are sub-dependencies or dependencies of other plugins. Using cordova@7 or above, the dependencies of this plugin should be satisfied by Cordova via npm.

Seems like something is going wrong with that dependency resolution or with your local node_modules. You could try to reproduce it in an isolated test project to rule out conflicts with other plugins.

dpa99c commented 5 years ago

Closed due to no response from OP

cquezpro commented 5 years ago

image @dpa99c I got same error now.

marcus13371337 commented 5 years ago

Same error!

expcapitaldev commented 5 years ago

check if cordova-custom-config is added in package.json in dependencies node