简体   繁体   中英

TypeError: Cannot read property 'name' of undefined ionic

I am making a project in Ionic.

When I tried ionic cordova build ios -- --buildFlag="-UseModernBuildSystem=0" an error occurred

TypeError: Cannot read property 'name' of undefined

To know the deeper cause --verbose when using

 at /Users/myname/ionic/platforms/ios/cordova/lib/build.js:130:60

I was able to identify this as the source of the error but I don't know this error solution.

var promise = require('./list-emulator-build-targets').targetForSimIdentifier(newTarget);
return promise.then(function (theTarget) {
    if (!theTarget) {
        return getDefaultSimulatorTarget().then(function (defaultTarget) {
            emulatorTarget = defaultTarget.name;
            events.emit('log', 'Building for ' + emulatorTarget + ' Simulator');
            return emulatorTarget;
        });
    } else {
        emulatorTarget = theTarget.name;
        events.emit('log', 'Building for ' + emulatorTarget + ' Simulator');
        return emulatorTarget;
    }
});

this error course MacOS Catalina

https://github.com/apache/cordova-ios/issues/427#issuecomment-503522317

fix code platform/ios/cordova/liblist-emulator-build-targets

var availableDevices = Object.keys(devices).reduce(function (availAcc, deviceCategory) {
    var availableDevicesInCategory = devices[deviceCategory];
    availableDevicesInCategory.forEach(function (device) {
        if (device && device.name === deviceType.name.replace(/\-inch/g, ' inch') && device.isAvailable == true) {
           availAcc.push(device);
        }
     });
     return availAcc;
}, []);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM