Closed sinedied closed 6 years ago
I ran the exact commands above and the prepare
operation worked fine and without errors (see console output below).
The errors you describe indicate the plugin's hook script is for some reason having problems resolving its node module dependencies:
Error: Cannot read property 'getConfigXml' of undefined
This will be generated from this line because require()
has failed to resolve the fileUtils
module here.
Error: Error loading dependencies - ensure the plugin has been installed via cordova-fetch or run 'npm install cordova-custom-config': Cannot find module 'tostr'
This is thrown by the hook script because it threw an exception while loading dependencies because the tostr
module couldn't be found.
I'm not sure why the node dependency resolution is failing in your enviroment and not mine.
The most likely cause I can think of is an upstream node error which is causing cordova-fetch
to fail to resolve the plugin dependencies.
You could try changing your node version e.g. to node@6
.
I'm using nvm to manage mine on OSX, so it's easy to switch.
I tested your steps with node@6.11.0
/npm@3.10.10
and the prepare
operation worked fine also.
I just missed a change I made in the meantime to fix this issue, that is not present in this repo: I added npm@5
as a local dependency, because cordova-lib
use an outdated npm@2
to fetch dependencies and it fails because of issue with peerDependencies
π
Without this it works as you tested, but the initial issue is still present π Anyway this has more to do with the way cordova retrieve its dependencies that your lib, the error coming from your code was just a side effect.
If anyone comes to this, its seems that using npm@3
instead of npm@5
as a local dependency seems to work around both issues π€£
Sorry for the noise and thanks for taking the time to test on your side!
Again, the dependencies issue popped up back again with cordova@8
, as the npm local dependency is no longer needed. π
Running cordova prepare
ends up with this error:
(node:77707) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): 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 'tostr'
No problem in my build env with cordova@8
, see console output below:
@dpa99c The repo has still not been updated and use a local cordova@7 version, which does not have the issue.
The problem is that when using cordova prepare
with cordova@8, it fails installing plugins' npm dependencies correctly if they are not properly specified in your package.json
.
With cordova@7 cordova prepare
updated package.json
if the entries were not present, but that's not the case anymore with cordova@8 (not sure if it's a bug or by design...).
The workaround I found is to run prepare with cordova@7 to update the package.json
file, then update to cordova@8 and now the error is not there (obviously) since your plugin package is properly installed by npm with npm install
even before running cordova prepare
.
I'm not sure what to think of this, but at least it works π
OK, but here's a different example which doesn't use a local Cordova version, so definitely using cordova@8
and that also works fine.
Please give this one a try:
Whatever I try, I still have issue with
cordova prepare
and this plugin.I'm using latest
cordova@7
version withnode@8
andnpm@5
, and cordova fetch is enabled (running on OSX).I have this error every time:
If I try to run
cordova prepare
again:If I remove this plugin,
cordova prepare
works perfectly, and installing it after withcordova plugin add cordova-custom-config
works without issue.Seems that
cordova prepare
does something your plugin do not seems to like πTo reproduce it:
git checkout cordova/ionic
npm install
npm run cordova:prepare
(build app then runcordova prepare
using local cordova dependency)