Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic fails building in macos 12 (Monterey)

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)
like image 906
Leonardo Nomdedeu Avatar asked Jul 09 '21 14:07

Leonardo Nomdedeu


4 Answers

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']]
]);
like image 174
LordMOS Avatar answered Sep 28 '22 10:09

LordMOS


This worked for me:

npm uninstall -g cordova
npm install -g [email protected]
like image 26
Teran Peterson Avatar answered Oct 01 '22 10:10

Teran Peterson


To fix it, simply install the latest macos-release, using npm install [email protected] --save and MacOS 12 (Monterey) will be defined.

like image 37
frankyt79 Avatar answered Sep 30 '22 10:09

frankyt79


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.

like image 30
Leonardo Nomdedeu Avatar answered Sep 28 '22 10:09

Leonardo Nomdedeu