When I run "ionic cordova build ios" on my newly updated macos 12 (Monterey) I'm receiving this error:
Uncaught Exception:
TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
at macosRelease (/Applications/XXX.app/Contents/Resources/app.asar/node_modules/macos-release/index.js:26:26)
at Object.<anonymous> (/Applications/XXX.app/Contents/Resources/app.asar/main/utils/errors.js:54:17)
at Module._compile (internal/modules/cjs/loader.js:968:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:986:10)
at Module.load (internal/modules/cjs/loader.js:816:32)
at Module._load (internal/modules/cjs/loader.js:728:14)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
at Module.require (internal/modules/cjs/loader.js:853:19)
at require (internal/modules/cjs/helpers.js:74:18)
edit nameMap like this
const nameMap = new Map([
[21, ['Monterey', '12']],
[20, ['Big Sur', '11']],
[19, ['Catalina', '10.15']],
[18, ['Mojave', '10.14']],
[17, ['High Sierra', '10.13']],
[16, ['Sierra', '10.12']],
[15, ['El Capitan', '10.11']],
[14, ['Yosemite', '10.10']],
[13, ['Mavericks', '10.9']],
[12, ['Mountain Lion', '10.8']],
[11, ['Lion', '10.7']],
[10, ['Snow Leopard', '10.6']],
[9, ['Leopard', '10.5']],
[8, ['Tiger', '10.4']],
[7, ['Panther', '10.3']],
[6, ['Jaguar', '10.2']],
[5, ['Puma', '10.1']]
]);
This worked for me:
npm uninstall -g cordova
npm install -g [email protected]
To fix it, simply install the latest macos-release, using npm install [email protected] --save
and MacOS 12 (Monterey) will be defined.
After digging the source code of the "macos-release" library I found that the 'Monterey' version was not present in this array and that was the cause of the problem:
const nameMap = new Map([
[20, ['Big Sur', '11']],
[19, ['Catalina', '10.15']],
[18, ['Mojave', '10.14']],
[17, ['High Sierra', '10.13']],
[16, ['Sierra', '10.12']],
[15, ['El Capitan', '10.11']],
[14, ['Yosemite', '10.10']],
[13, ['Mavericks', '10.9']],
[12, ['Mountain Lion', '10.8']],
[11, ['Lion', '10.7']],
[10, ['Snow Leopard', '10.6']],
[9, ['Leopard', '10.5']],
[8, ['Tiger', '10.4']],
[7, ['Panther', '10.3']],
[6, ['Jaguar', '10.2']],
[5, ['Puma', '10.1']]
]);
This "macos-release" library was a dependency of "cordova": "^9.0.0", so the solution that worked for me was to remove this library from my package.json file, delete "node-modules" folder an install all the dependencies again.
Another solution would be upgrading to cordova 10.0.0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With