cordova-browser: Cordova requirements crash with "Cannot read property 'forEach' of undefined"

Version used: 5.0.3 and 5.0.4

After running:

cordova requierements

it prints:

$ cordova requirements -d

Checking opts.platforms  :
PlatformApi successfully found for platform browser
PlatformApi successfully found for platform ios

Requirements check results for browser:
Cannot read property 'forEach' of undefined
TypeError: Cannot read property 'forEach' of undefined
    at /usr/local/lib/node_modules/cordova/src/cli.js:406:35
    at Array.map (<anonymous>)
    at /usr/local/lib/node_modules/cordova/src/cli.js:397:68
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:854:54)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:624:44
    at runSingle (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:137:13)
    at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:125:13)
    at process._tickCallback (internal/process/next_tick.js:61:11)

After adding some logs on cordova/clj.js I was able to see an undefined in the platformChecks from https://github.com/apache/cordova-cli/blob/master/src/cli.js#L375:

Debug-Values: browser undefined
Debug-Values: ios [object Object],[object Object],[object Object],[object Object]

Any idea if this is caused by this plugin or by my configuration?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 15 (5 by maintainers)

Most upvoted comments

(Which reminds me we should just make sure that a .gitignore is generated for new projects: https://github.com/apache/cordova-app-hello-world/issues/30)

@janpio tried from master and it prints:

Cannot read property 'version' of undefined
TypeError: Cannot read property 'version' of undefined
    at /usr/local/lib/node_modules/cordova/src/cli.js:391:83
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/cordova/src/cli.js:388:39
    at Array.map (<anonymous>)
    at /usr/local/lib/node_modules/cordova/src/cli.js:375:68
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:854:54)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:624:44
    at runSingle (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:137:13)

But it looks like master is behind 8.1.2 (older than npm repository one)

Have the same error with 9.0.0 (cordova-lib@9.0.1). In my case, an error appeared after removing all the platforms and adding an old android@5.1

This issue has been resolved in https://github.com/apache/cordova-browser/pull/61 and in browser@6.0.0.

If someone would do cordova requirements on a project with multiple platforms including browser and iOS, it would stop with the error message on browser and miss iOS. I would classify this as a UX issue in general, too bad we missed apache/cordova-cli#335 when we made the patch release in October.

I just raised https://github.com/apache/cordova-cli/pull/366 with a proposal to release the solution in apache/cordova-cli#335 in a patch release. Too bad we missed it when we made the cordova-cli patch release last October.

I cannot promise when I or anyone else will have a chance to make the new cordova-cli release.