Build fails with Cannot read property 'reject' of undefined

Viewed 2565

I have an ionic app and I am trying to build it for iOS and android. It runs well via ionic serve. No errors.

$ cordova build ios --buildFlag='-UseModernBuildSystem=0' 
Cannot read property 'reject' of undefined

No other message.

Running with --verbose gives

$ cordova build ios --buildFlag='-UseModernBuildSystem=0' --verbose 
No scripts found for hook "before_build".
Executing script found in plugin cordova-custom-config for hook "before_prepare": plugins/cordova-custom-config/hooks/restoreBackups.js
Cannot read property 'reject' of undefined
TypeError: Cannot read property 'reject' of undefined
    at module.exports (/Users/mj/rethink/3/rethink/plugins/cordova-custom-config/hooks/restoreBackups.js:134:18)
    at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:181:32)
    at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:157:16)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:125:20
    at process._tickCallback (internal/process/next_tick.js:43:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:777:11)
    at executeUserCode (internal/bootstrap/node.js:342:17)
    at startExecution (internal/bootstrap/node.js:276:5)
    at startup (internal/bootstrap/node.js:227:5)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
1 Answers

do a

$ cordova plugin ls

to list your plugins.

You will see:

cordova-custom-config 5.0.2 "cordova-custom-config"

This is the one causing the build failure.

to fix, remove and add version 5.1.0

However, when removing the plugin, we get the same error:

$ cordova plugin rm cordova-custom-config
Cannot read property 'reject' of undefined

So to fix that, remove the plugin manually:

$ rm -rf plugins/cordova-custom-config/
Apples-iMac:rethink mj$ cordova plugin rm cordova-custom-config
Plugin "cordova-custom-config" is not present in the project. See `cordova plugin list`.

Add the correct version of the plugin:

$ cordova plugin add cordova-custom-config@5.1.0
Plugin "cordova-custom-config" already installed on android.
Adding cordova-custom-config to package.json

And build again:

$  cordova build ios --buildFlag='-UseModernBuildSystem=0' --verbose 
..
..
..

** BUILD SUCCEEDED **

No scripts found for hook "after_compile".
No scripts found for hook "after_build".

Hope this helps.

Also see: https://github.com/apache/cordova-cli/issues/415

Related