TypeError: Cannot read property 'length' of undefined (ionic package build)

I get the following error when trying to use ionic to build a package.

I have a build profile for android called build
$ ionic package build android --profile build ✔ Retrieving security profile build - done! TypeError: Cannot read property 'length' of undefined
I have removed node_modules, updated to the latest versions of all the packages in package.json, and then reinstalled the node modules. No dice.

Please, someone, help?

I’m getting the same message… have you solved this? Anyone else?

It’s unlikely someone can answer this unless you post your ionic info and package.json. As for me, no I’ve never encountered that build error.

Thanks for anwering. I’ve now updated all my packages and it works. Don’t know which update that did the trick.

Still I facing same error. Can you please tell me the update comand

I updated to ionic 3.5.3 https://github.com/ionic-team/ionic/blob/master/CHANGELOG.md#steps-to-upgrade

Then I run sudo npm outdated and tried update every package in that list to the latest. Typescript had to be 2.3.4.

Either you can update everyt package one by one (I did :)) or edit your package.json and then remove your node_modules folder and run sudo npm install

Here is my package.json

{
    "name": "XX",
    "author": "",
    "homepage": "",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "^4.1.3",
        "@angular/compiler": "^4.1.3",
        "@angular/compiler-cli": "^4.1.3",
        "@angular/core": "^4.1.3",
        "@angular/forms": "^4.1.3",
        "@angular/http": "^4.1.3",
        "@angular/platform-browser": "^4.1.3",
        "@angular/platform-browser-dynamic": "^4.1.3",
        "@ionic-native/camera": "^4.1.0",
        "@ionic-native/core": "^4.1.0",
        "@ionic-native/file": "^4.1.0",
        "@ionic-native/in-app-purchase": "^4.1.0",
        "@ionic-native/splash-screen": "^4.1.0",
        "@ionic-native/status-bar": "^4.1.0",
        "@ionic/cloud-angular": "^0.12.0",
        "@ionic/storage": "2.0.1",
        "ajv": "^5.2.2",
        "cordova-android": "^6.2.3",
        "cordova-ios": "^4.2.1",
        "cordova-plugin-camera": "^2.4.1",
        "cordova-plugin-compat": "^1.1.0",
        "cordova-plugin-device": "^1.1.4",
        "cordova-plugin-file": "^4.3.3",
        "cordova-plugin-inapppurchase": "^1.1.0",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.2",
        "cordova-plugin-whitelist": "^1.3.1",
        "ionic-angular": "^3.5.3",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "object-keys": "^1.0.11",
        "rxjs": "^5.4.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "^0.8.12"
    },
    "devDependencies": {
        "@ionic/app-scripts": "^2.0.2",
        "@ionic/cli-plugin-cordova": "^1.4.1",
        "@ionic/cli-plugin-ionic-angular": "^1.3.2",
        "typescript": "^2.3.4"
    },
    "description": "",
    "cordova": {
        "plugins": {
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-inapppurchase": {},
            "cordova-plugin-camera": {},
            "cordova-plugin-file": {}
        },
        "platforms": [
            "android",
            "ios"
        ]
    }
}