Error when build or run


#1

hello
i got error when build or run for ios or android app from terminal in ionic 3

[WARN] Error occurred during command execution from a CLI plugin. Your plugins may be
out of date.
TypeError: Cannot read property 'length' of undefined

the app work normally when serve it

this is my package.json



{
    "name": "ward44",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "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.0",
        "@angular/compiler": "4.1.0",
        "@angular/compiler-cli": "4.1.0",
        "@angular/core": "4.1.0",
        "@angular/forms": "4.1.0",
        "@angular/http": "4.1.0",
        "@angular/platform-browser": "4.1.0",
        "@angular/platform-browser-dynamic": "4.1.0",
        "@ionic-native/core": "3.7.0",
        "@ionic-native/in-app-browser": "^3.10.3",
        "@ionic-native/splash-screen": "3.7.0",
        "@ionic-native/status-bar": "3.7.0",
        "@ionic/storage": "2.0.1",
        "cordova-android": "^6.2.3",
        "cordova-ios": "^4.4.0",
        "cordova-plugin-console": "1.0.5",
        "cordova-plugin-crosswalk-webview": "~2.3.0",
        "cordova-plugin-device": "1.1.4",
        "cordova-plugin-inappbrowser": "^1.7.1",
        "cordova-plugin-media-capture": "*",
        "cordova-plugin-splashscreen": "~4.0.1",
        "cordova-plugin-statusbar": "2.2.2",
        "cordova-plugin-whitelist": "1.3.1",
        "ionic-angular": "3.2.1",
        "ionic-plugin-keyboard": "~2.2.1",
        "ionicons": "3.0.0",
        "onesignal-cordova-plugin": "~2.1.1",
        "rxjs": "5.1.1",
        "sw-toolbox": "3.4.0",
        "zone.js": "^0.8.10"
    },
    "devDependencies": {
        "@ionic/app-scripts": "1.3.7",
        "@ionic/cli-plugin-cordova": "1.0.0",
        "@ionic/cli-plugin-ionic-angular": "1.2.0",
        "typescript": "~2.2.1"
    },
    "description": "An Ionic project",
    "cordova": {
        "platforms": [
            "android",
            "ios"
        ],
        "plugins": {
            "cordova-plugin-console": {},
            "cordova-plugin-crosswalk-webview": {},
            "cordova-plugin-device": {},
            "cordova-plugin-media-capture": {
                "CAMERA_USAGE_DESCRIPTION": "App would like to access the camera.",
                "MICROPHONE_USAGE_DESCRIPTION": "App would like to access the microphone.",
                "PHOTOLIBRARY_USAGE_DESCRIPTION": "App would like to access the library."
            },
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "onesignal-cordova-plugin": {},
            "cordova-plugin-inappbrowser": {}
        }
    }
}

#2

please help me to solve this


#3

Two things to try:

Update all packages to latest, delete your node_modules and run npm install

Make sure all your files and folders are lower case and the references to them in the .ts import statements are also lower case.


#4

Sorry about the previous typo :slight_smile: ‘Erosions’ lol.
iPhone typing!


#5

I am having the same issue here. I just get a generic “Error: Cannot read property ‘length’ of undefined”

This occurs just after cordova build begins to start.

I read your above answer, but I am a little curious as to how to update all packages to the latest? What exactly are packages (how can I decipher which ones I need to run an update command on, or is there a master command that will find and update all for me?).

Can you provide a more itemized way to begin troubleshooting this? I have already cloned my repository to a new folder, done a fresh npm install, npm install -g cordova && npm install -g ionic, as well as npm install for my other dependent modules and added plugins back to the app.

FWIW, this issue started with an upgrade to Ionic 3, and has followed as I deleted my existing project folder and cloned from the repository.

Thanks for any help in advance.

-LB


#6

Not sure your problem is the same albeit with similar symptoms.

To test building at all can you try building for browser and see if that works? That would eliminate the Ionic/Cordova side and square the blame at the Java side…

ionic cordova build browser --prod

#7

Also on the front of up-to-date packages - I’m referring to your packages.json file.

You If you are using VSCode you can get a plugin called ‘Version Lens’ which shows you what you currently have and what’s the latest…


#8

I am able to ionic serve (and run through the test environment) and things run fine. I will try the browser now and get back with you.

Also, I’ll have to slow down my responses since I am replying to quickly ;).

I will check into version lens plugin and see what I cannot figure out. More to come, thanks for your reply.


#9

Ok… It appears I cannot build to browser either.

I get an error:

TypeError: Cannot Read Property ‘codeGen’ of undefined.

I looked through the packages.json and everything meets the requirements (though some are not the latest).

Any ideas as to a logical next step?

Attached is also an image of packages.json (which has GROWN since the upgrade :)).


#10

what is the difference between “building for browser” and “ionic serve?”


#11

Produces a build which you could deploy to web servers I think.

It’s a production version which removes all the debug code from the payload.


#12

Upgrade your stuff, remove the node_modules directory - npm install, try again…?


#13

Can you pretty please post text as text, not as images?


#14

Geting the same result, when I run

ionic cordova run android --verbose

Error: Cannot read property ‘length’ of undefined.

on the intial build I get a

Throwing PLUGIN_NOT_INSTALLED for global @ionic/cli-plugin-proxy (though I am not using a proxy server).

If I do…

ionic cordova build browser --prod

It IS successful. This is also giving the:

Throwing PLUGIN_NOT_INSTALLED for global @ionic/cli-plugin-proxy

but continues and succeeds to build.

scratching my head

I did get some unmet dependency warnings for react and rxjs when I ran npm install… That’s about the only other clue I see popping up right now? (I tried to force – npm install react and npm install rxjs but neither was successful).


#15

Last thing to try…

This is a little more effort - but if you have an ionic account, try letting Ionic build it to see if it’s possible.

ionic package build android --prod

It’ll build it obv without a certificate, but will eliminate this time your own computer.


#16

This one kicks out with a

TypeError: Cannot read property ‘codeGen’ of undefined


#17

Are you in a position to share the code with me?

I’ve seen an article that suggests a version mismatch with angular…


#18

Yes I can. What is the best way to get you something?


#19

Hi,

GitHub is always easiest.

If you don’t want to publicly share just share with my account, judgewest2000.


#20

Sorry for the delay in response. I ended up moving the dot a little further last night. I found a few of the dependencies were not actually upating on npm update (I had to update packages.json manually then ensure that dependencies were installed correctly on npm install – even then some I had to do npm update @latest).

I found a multitude of items broken (a lot of ionic-native and some older plugins like splash-screen, etc., as well as angularfire2 and some image map stuff) after the update. I started trying to find and fix those dependencies but there were way to many changes in a lot of them (angularfire2 is pretty drastically different from 2.0.0 to 4.0.0) to fix them in one fell swoop.

I am going back to ionic 2.2.1 (my colleague got our project working in that version) and I will slowly start updating modifying my dependencies from there, one by one.

It seems we may have been a bit overzealous in trying to jump to ionic 3 :slight_smile:, so we are going to take our foot off the gas and try to do this incrementally. I will update you with any errors / problems I may run into – but for now I think to many things are changing at once to accurately pinpoint a single error.

Thanks for your patience and help with this; it is really appreciated.