ionic-team / ionic-cli

The Ionic command-line interface
MIT License
2k stars 654 forks source link

Exception: Using cordova-fetch for cordova-ios@^4.5.0 #2759

Closed CosmicWebServices closed 5 years ago

CosmicWebServices commented 7 years ago

Description: I updated ionic-cli to 3.12.0 and I started getting this error:

[ERROR] Exception: Using cordova-fetch for cordova-ios@^4.5.0

Steps to Reproduce:

  1. Update cordova-cli to 3.12.0 from 3.11.x
  2. Try running cordova ionic build ios

Output:

DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/Users/andrewrodebaugh/aqua', local: true, binPath: '/usr/local/lib/node_modules/ionic/bin/ionic', 
        libPath: '/Users/andrewrodebaugh/aqua/node_modules/ionic/dist/index.js' }
[DEBUG] Daemon found (pid: 19777)
> cordova platform add ios --save
✖ Running command - failed!
[ERROR] Exception: Using cordova-fetch for cordova-ios@^4.5.0

        Error: Failed to fetch platform cordova-ios@^4.5.0
        Probably this is either a connection problem, or platform spec is incorrect.
        Check your connection and platform name/version/URL.
        Error: npm: Command failed with exit code 1 Error output:
        npm ERR! Darwin 17.0.0
        npm ERR! argv "/usr/local/bin/node" "/Users/andrewrodebaugh/aqua/node_modules/.bin/npm" "install" 
        "cordova-ios@^4.5.0" "--save"
        npm ERR! node v6.11.3
        npm ERR! npm  v2.15.12
        npm ERR! code EPEERINVALID

        npm ERR! peerinvalid The package @angular/common@4.4.3 does not satisfy its siblings' peerDependencies 
        requirements!
        npm ERR! peerinvalid Peer @angular/forms@4.4.3 wants @angular/common@4.4.3
        npm ERR! peerinvalid Peer @angular/platform-browser@4.4.3 wants @angular/common@4.4.3
        npm ERR! peerinvalid Peer @angular/platform-browser-dynamic@4.4.3 wants @angular/common@4.4.3
        npm ERR! peerinvalid Peer @angular/platform-server@4.4.3 wants @angular/common@4.4.3
        npm ERR! peerinvalid Peer @angular/router@4.4.3 wants @angular/common@4.4.3
        npm ERR! peerinvalid Peer ionic-angular@3.6.1 wants @angular/common@4.1.3

        npm ERR! Please include the following file with any support request:
        npm ERR!     /Users/andrewrodebaugh/aqua/node_modules/npm-debug.log

My ionic info:

cli packages: (/Users/andrewrodebaugh/aqua/node_modules)

    @ionic/cli-utils  : 1.12.0
    ionic (Ionic CLI) : 3.12.0

global packages:

    cordova (Cordova CLI) : 7.0.1 

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : browser 4.1.0 ios 4.4.0
    Ionic Framework    : ionic-angular 3.6.1

System:

    Node  : v6.11.3
    npm   : 2.15.12 
    OS    : macOS High Sierra
    Xcode : Xcode 9.0 Build version 9M137d 

Misc:

    backend : legacy

Other Information:

npm-debug.log https://gist.github.com/CosmicWebServices/d81ae61f49958dc9bc5b59ed9266d123

imhoffd commented 7 years ago

This isn't because of the CLI update. These are npm errors. Please use the latest npm 3 or npm 5. npm 2 originates ~2014.

npm install npm -g

santiagobernalbetancourt commented 7 years ago

how to update CLI?

jamesdixon commented 7 years ago

FYI I've had all kinds of issues with this and NPM 5. Always have to revert to NPM 4 (Node 7) to get things working.

FallenRiteMonk commented 7 years ago

In my case this is some kind of problem with having cordova installed locally. To fix this just remove the locally install version of cordova and then it should work!

@dwieeb is cordova somehow specifying a version of npm since the log clearly states it uses a npm 2.x version while i have 5.x installed on my dev machine?

felixja commented 7 years ago

I had similar problems and for me it was related to having npm installed both globally and locally. When I updated npm I always did on the global because I didn’t even know I had it locally too, so for the project it kept using the 2.15 version and a lot of things were broken and giving problems.

Removing npm locally and installing globally, or specifically updating npm locally, solved my problems and everything worked like a charm since that.

Hope it helps

saarmic commented 7 years ago

@FallenRiteMonk did you find any solution, mine is also using nom 2.x however I have nom 4.1.2 installed


Exception: Using cordova-fetch for cordova-ios@^4.4.0

        Error: Failed to fetch platform cordova-ios@^4.4.0
        Probably this is either a connection problem, or platform spec is incorrect.
        Check your connection and platform name/version/URL.
        Error: npm: Command failed with exit code 1 Error output:
        npm ERR! Darwin 16.7.0
        npm ERR! argv "/Users/aunrizvi/.nvm/versions/node/v7.7.0/bin/node" 
        "/Users/aunrizvi/Documents/GitHub/Fixonclick-Mobile/node_modules/.bin/npm" "install" "cordova-ios@^4.4.0" 
        "--save"
        npm ERR! node v7.7.0
        npm ERR! npm  v2.15.12
        npm ERR! code EPEERINVALID```
felixja commented 7 years ago

@saarmic dis you tried what I suggested? update npm both globally and non globally:

npm install -g npm@latest and npm install npm@latest

I was stucked on that same problem during hours... I wasn't able to download the cordova-ios as well. I (suppose to) had the last version of npm, but kept telling me that it was 2.15.12. Upgrading the both solved it for me.

FallenRiteMonk commented 7 years ago

@saarmic as far as I have tested removing cordova localy solved the problem: npm unistall cordova --save or --save-dev if you have it as dev dep. I havent tested it myself but also @felixja solution should do the trick, just also install npm locally: npm install npm --save-dev maybe even specify the same version as you have installed globaly: npm install npm@4.1.2 --save-dev

viki53 commented 7 years ago

Weirdly enough, @felixja 's solution fixed the issue on my part.

Seems counter-intuitive to have npm installed locally though…

felixja commented 7 years ago

I think In my case was a remainder for the first time I was using npm and I didn't have any idea of what the -g meant, so I think I installed it with and without it...

The real solution is this case I think should be something similar to remove npm locally and keep it just globally. But I didn't try, Anyway it was difficult to found this solution as there was not much info on stackoverflow or here on github about this and I spent a lot of time searching why my npm version was always that 2.15.12. I hope this can bring light to more people, because for me it was not just causing the problem for downloading cordova-ios, I was having much more troubles that were solved after I was able to fix.

saarmic commented 7 years ago

Thanks guys, @felixja , @viki53, @FallenRiteMonk and @CosmicWebServices

npm install npm@4.1.2 --save-dev

did saved me, however I want to add a few observations: I had Cordova in my --dev dependencies, which is not required. As I am having Cordova in dev dependencies then for building the iOS platform the dev version of Cordova is used along with the .npm folder which is in the local node modules and not the global npm. which is the reason that even after npm install npm@latest -g was not working and instead the Cordova was using the local npm version which was 2.4.x

so the solution is:

  1. Remove Cordova from local dependencies.
  2. do npm install npm@4.1.2 --save-dev (optional, you can use your own global version of npm instead of 4.1.2)
  3. run ionic cordova platform add ios
  4. and then ionic cordova build ios --prod --release
imhoffd commented 7 years ago

Is there a benefit of having npm installed locally?

FallenRiteMonk commented 7 years ago

@dwieeb no I don't think there is any specific benefit as long as your project doesn't require a specific version of npm, but it seems to be mandatory if your project uses a local version of cordova due to the above mentioned error!

beenotung commented 7 years ago

I have the similar problem but it doesn't appear when I'm using package-lock.json from my collaborator (from earlier time).

part of the error log:

2754 error Linux 4.13.5-1-ARCH
2755 error argv "/usr/local/bin/node" "/home/beenotung/workspace/bitbucket.org/freedom-software/peer-coin-exchange-ionic/node_modules/.bin/npm" "install" "cordova-browser@~4.1.0" "--save"
2756 error node v8.6.0
2757 error npm  v2.15.12
2758 error code EPEERINVALID
2759 error peerinvalid The package @angular/core@4.4.3 does not satisfy its siblings' peerDependencies requirements!
2759 error peerinvalid Peer @angular/common@4.4.3 wants @angular/core@4.4.3
2759 error peerinvalid Peer @angular/forms@4.4.3 wants @angular/core@4.4.3
2759 error peerinvalid Peer @angular/http@4.4.3 wants @angular/core@4.4.3
2759 error peerinvalid Peer @ionic-native/geolocation@4.3.1 wants @angular/core@*
2759 error peerinvalid Peer @ionic-native/splash-screen@4.3.1 wants @angular/core@*
2759 error peerinvalid Peer @ionic-native/status-bar@4.3.1 wants @angular/core@*
2759 error peerinvalid Peer @ionic-native/unique-device-id@4.3.1 wants @angular/core@*
2759 error peerinvalid Peer @ionic/storage@2.0.1 wants @angular/core@*
2759 error peerinvalid Peer @ngx-translate/core@8.0.0 wants @angular/core@>=4.0.0
2759 error peerinvalid Peer @ngx-translate/http-loader@2.0.0 wants @angular/core@>=4.3.0
2759 error peerinvalid Peer angularlib@1.0.2 wants @angular/core@^4.0.0
2759 error peerinvalid Peer ionic-angular@3.7.1 wants @angular/core@4.4.3
2759 error peerinvalid Peer @angular/compiler@4.4.3 wants @angular/core@4.4.3
2759 error peerinvalid Peer @angular/platform-browser@4.4.3 wants @angular/core@4.4.3
2759 error peerinvalid Peer @angular/platform-browser-dynamic@4.4.3 wants @angular/core@4.4.3
2759 error peerinvalid Peer codelyzer@3.2.1 wants @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0
2759 error peerinvalid Peer @angular/compiler-cli@4.4.3 wants @angular/core@4.4.3
2760 verbose exit [ 1, true ]

the package-lock.json https://gateway.ipfs.io/ipfs/QmUmFrBrtFhpucS7JB9enwANsFYvxBZmsB7Fz4qNbrWyFs

fdambrosio commented 7 years ago

It's not fixed. I have the same problem after the ionic-cli update.

@ionic/cli-utils  : 1.13.1
ionic (Ionic CLI) : 3.13.2

global packages:

cordova (Cordova CLI) : 7.0.1

local packages:

@ionic/app-scripts : 3.0.0
Cordova Platforms  : ios 4.5.2
Ionic Framework    : ionic-angular 3.7.1

System:

ios-deploy : 1.9.2
ios-sim    : 6.1.2
Node       : v6.11.2
npm        : 5.5.1
OS         : macOS Sierra
Xcode      : Xcode 9.0 Build version 9A235
imhoffd commented 7 years ago

@fdambrosio The issue won't be fixed by updating the Ionic CLI because it's not an issue with the Ionic CLI. Did you read the proposed solution here? https://github.com/ionic-team/ionic-cli/issues/2759#issuecomment-334405577

I believe this will also fix the issue:

  1. Make sure you're on the latest npm.
  2. Run this:
npm uninstall npm
smccamley commented 7 years ago

Hi all, I am completely lost here. I have tried every possible solution in this list .... none has worked. I have had 2 days of banging my head against the wall with ionic and COUNTLESS errors and problems.

I got the app to build twice about 1 hour ago after running npm install cordova-fetch

I have changed nothing and now it's back ...

What I have tried ... 1) everything above 2) reinstalling cordova 3) reinstalling ionic + ionic cli 4) changing node version

@ionic/cli-utils  : 1.12.0
ionic (Ionic CLI) : 3.12.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : ios 4.5.2
Ionic Framework    : ionic-angular 3.6.1

System:

Android SDK Tools : 26.1.1
ios-deploy        : 1.9.2
ios-sim           : 6.1.2
Node              : v6.11.3
npm               : 5.5.1
OS                : macOS Sierra
Xcode             : Xcode 8.3.3 Build version 8E3004b

Misc:

backend : pro
imhoffd commented 7 years ago

@smccamley I would recommend not manually invoking npm install cordova-ios. Cordova needs much more than the npm package to have the ios platform installed properly, and Cordova controls the version of the platform installed whereas npm installs the latest.

Can you post the full output of cordova platform add ios?

smccamley commented 7 years ago

Sure, and thank you for responding, I got soo frustrated with it and so went for a 🍺 I'll post it in the morning!

beenotung commented 7 years ago

@smccamley at least a newly created project from start myapp blank works for both browser and android, try to copy the app into a new project for the versioning issue if that helps

also, see if the package.json, package-lock.json and yarn.lock of a project I'm working here helps https://ipfs.io/ipfs/QmTNauGBk772a3cuXxZ3gzyf8v85W95TxX5X2Vdg48ZHEp/ (some non-related fields are removed)

smccamley commented 7 years ago
> cordova platform add ios --save
✖ Running command - failed!
[ERROR] Exception: Using cordova-fetch for cordova-ios@4.5.2

        Adding ios project...
        Creating Cordova project for the iOS platform:
                Path: platforms/ios
                Package: io.proteam.proteam
                Name: ProTeam
        iOS project created with cordova-ios@4.5.2
        Error: Source path does not exist: resources/ios/icon/icon-small@2x.png

Is the full output of my command. Also I was wrong before, i did not do npm install cordova-ios I actually did npm install cordova-fetch however I believe this to have been a red herring, I now feel that the problem is intermittent and feels more random. Sometimes the platform will add, sometimes it will not.

tskweres commented 7 years ago

I can't add any plugins. I tried removing and re-adding ionic cordova platform ios, but now I can't add the platform :(

imhoffd commented 7 years ago

@smccamley The error Source path does not exist: resources/ios/icon/icon-small@2x.png can be fixed by running ionic cordova resources to generate appropriately sized icons and splash screens from your source images at resources/icon.png and resources/splash.png. See ionic cordova resources --help for more information. You can also download our default resources and replace resources/ with the contents of the repo.

@tskweres I really need specifics if I'm going to be able to help you. Your ionic info output and a full error message would be a good start.

tskweres commented 7 years ago

so i ran npm install npm@4.1.2 --save-dev

ionic cordova platform add ios

this is the error I get:

cordova platform add ios --save ✖ Running command - failed! [ERROR] Exception: Using cordova-fetch for cordova-ios@^4.4.0

    Error: Failed to fetch platform cordova-ios@^4.4.0
    Probably this is either a connection problem, or platform spec is incorrect.
    Check your connection and platform name/version/URL.
    Error: npm: Command failed with exit code 1 Error output:
    module.js:529
         throw err;
         ^

    Error: Cannot find module 'lodash.pad'
         at Function.Module._resolveFilename (module.js:527:15)
         at Function.Module._load (module.js:476:23)
         at Module.require (module.js:568:17)
         at require (internal/module.js:11:18)
         at Object.<anonymous> 
    (/Users/travis/Dev/myapp/node_modules/npm/node_modules/npmlog/node_modules/gauge/progress-bar.js:5:11)
         at Module._compile (module.js:624:30)
         at Object.Module._extensions..js (module.js:635:10)
         at Module.load (module.js:545:32)
         at tryModuleLoad (module.js:508:12)
         at Function.Module._load (module.js:500:3)
imhoffd commented 7 years ago

@tskweres Please uninstall any local versions of npm in your project. Use a globally installed npm 3 if you're on Node 6 and npm 5 if you're on Node 8.

tskweres commented 7 years ago

Do you guys use cordova-ios 4.4 or 4.5.2? So I removed local versions of npm, i'm on global npm 5 and node 8

I ran:

> cordova platform add ios@4.5.2 --save
✖ Running command - failed!
[WARN] Platform already added. Saving platforms to config.xml.
> cordova platform save
✔ Running command - done!
> ionic cordova prepare ios

? Platform ios is not installed! Would you like to install it? Yes

Now I have this old issue of on every platform command it says the platform is not installed, even though it is.

Separately, I removed the platform and tried adding cordova-ios@4.4.0, and I get an error in my resources:

> cordova platform add ios@4.4.0 --save
✖ Running command - failed!
[ERROR] Exception: Using cordova-fetch for cordova-ios@4.4.0

        Adding ios project...
        Creating Cordova project for the iOS platform:
            Path: ../../dev/myapp/platforms/ios
            Package: org.myapp.app
            Name: MyApp
        iOS project created with cordova-ios@4.4.0
        Error: Source path does not exist: resources/ios/icon/icon-40.png

Which is interesting because without a platform, I can't run ionic cordova resources

imhoffd commented 7 years ago

@tskweres Are you on the latest Ionic CLI? Should be 3.13.2. Try not to specify a specific ios platform version, they're sometimes incompatible with the Cordova version.

tskweres commented 7 years ago

Yes i'm on 3.13.2. If I just run cordova platform add ios I get:

[ERROR] Exception: Using cordova-fetch for cordova-ios@~4.5.1

        Adding ios project...
        Creating Cordova project for the iOS platform:
            Path: ../../dev/myapp/platforms/ios
            Package: org.myapp.app
            Name: MyApp
        iOS project created with cordova-ios@4.5.2
        Error: Source path does not exist: resources/ios/icon/icon-small@2x.png
smccamley commented 7 years ago

@dwieeb thank you for getting back to me and asking for more info ... I am confusd by some of the statements made above.

  1. running ionic cordova resources before ionic cordova platform add ios, doing this results in the following error for me: No platforms detected. Please run: ionic cordova platform add
  2. npm 3 if you're on Node 6 and npm 5 if you're on Node 8, where is this information available to users of Ionic cli? how did you find this out? I am about to try this for myself and will report back the results below.

I have included the output of my ionic info below. I hope it helps!

cli packages: (/Users/user/Workspace/proteam/app/node_modules)

    @ionic/cli-utils  : 1.13.1
    ionic (Ionic CLI) : 3.13.2

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.6.1

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2
    ios-sim           : 6.1.2
    Node              : v6.11.3
    npm               : 5.5.1
    OS                : macOS Sierra
    Xcode             : Xcode 8.3.3 Build version 8E3004b

Misc:

    backend : pro
tskweres commented 7 years ago

What I'm running

npm@5.5.1 ionic@3.13.2 cordova@7.1.0

tskweres commented 7 years ago

So weird, so i run:

ionic cordova platform list
> cordova platform ls

✔ Running command - done!
Installed platforms:
  ios 4.5.2
Available platforms: 
  android ~6.3.0
  blackberry10 ~3.8.0 (deprecated)
  browser ~5.0.0
  osx ~4.0.1
  ubuntu ~4.3.4 (deprecated)
  webos ~3.7.0
  windows ~5.0.0
  www ^3.12.0

> ionic cordova prepare ios

? Platform ios is not installed! Would you like to install it? No
[ERROR] Can't prepare for ios unless the platform is installed.

It says I have ios 4.5.2 installed, but then i run ionic cordova prepare ios, and it says it's not installed.

smccamley commented 7 years ago

@tskweres I have the same problem I expect the platform failed to install in some way when we ran cordova platform add. (Not gonna lie I do miss working with react native ;-) )

tskweres commented 7 years ago

horrible bug - hours wasted. Ultimately to get around it I had to:

  1. completely delete my project
  2. run npm install ionic@latest cordova@latest -g and make sure I had the latest of all
  3. ionic start a new project with the latest package.json
  4. clone my repo from github again
  5. manually move over my package.json, plugins, and src files over to the new project

eventually I was able to get it built and running identically to the old one

tskweres commented 7 years ago

I think the culprit is the Ionic Native OneSignal plugin. I've removed it whenever I blow away and do platform like this, and everything works great. Then I just add it again after.

smccamley commented 7 years ago

@tskweres I am also using the OneSignal plugin and a range of others with Ionic. I think there are wider issues with regards to how all of the pieces of the puzzles interact.

Firstly there is a general issue with the way the config.xml and the package.json gets updated. I have found this very strange. There should be clear guidance on what edits what and how the scripts update these.

I have found the following problems cause this issue. 1) I have installed the following plugin https://github.com/nchutchind/cordova-plugin-streaming-media, this plugin when installed using the cordova cli adds the wrong id in the config.xml. This causes problems when doing cordova platform add. The reason for this error seems to be that the wrong plugin config.xml is downloaded. For this reason I have created my own plugin for streaming media and have been working on it today. 2) Once you start editing your package.json file and config.xml and make a mistake / version miss-match in your files then you will see the cordova fetch bug. You can recreate the bug by adding the following to your package.json "cordova-plugin-streaming-media-xtreme": "2.0.0", and the following in your config.xml (note the version numbers are not equal) <plugin name="cordova-plugin-streaming-media-xtreme" spec="2.1.0" />

So If you find this bug I would suggest: 1) Get any stable version of npm and node that work together and work with your version of the cordova cli, I am using

user@app$ node -v
v6.11.3
user@app$ npm -v
5.5.1

2) make sure you have all your plugin names in your package.json correctly aligned with the names in your plugins/ directory 3) make sure you have all the versions correctly installed 4) don't just trust this will work using the cordova cli commands or ionic commands. Double check

smccamley commented 7 years ago

I take it back, this issue has not been fixed using my fix above. It was working for a day and now fails continuously (and I feel like I have changed nothing, however adding new platforms seems to change al the version numbers of my package.json cordova plugins). At this point I am lost as to what is wrong and am a little taken aback by the number of issues I have experienced with this CLI

tskweres commented 7 years ago

Do these steps

  1. ionic cordova platform remove ios
  2. npm install ionic cordova -g
  3. npm uninstall npm
  4. npm uninstalll cordova
  5. ionic cordova platform add ios

This should get you past that issue. It stems from somehow npm and cordova getting installed locally, you want the global version, and the global version @latest

tskweres commented 7 years ago

If that doesn’t work you may need to also

rm -R node_modules locally and re npm install to get rid of the local version of cordova-ios, then you should probably also run npm uninstall npm and npm uninstall cordova ( both locally ) before re-adding platform iOS

gammelby commented 6 years ago

I observed the same odd behavior as @smccamley - in a specific configuration, the ionic cordova platform add ios always failed as noted above. In subsequent runs it succeeded with no config changes. Tried everything suggested here (including uninstalling everything, reinstalling, cleaning npm cache and synchronizing version numbers between config.xml and package.json). Downgrading to cordova 6.5 makes it succeed in the first run so probably something related to my package.json file as it is apparently not used by the older version.

The project in question with the failing configs can be seen here if curious: https://github.com/nabto/ionic-starter-nabto

The same project works fine with Cordova 8.0 on another machine (npm version 5.3 and node 8.0.0 there)

Ionic info on my machine (after downgrading cordova, though):

cli packages: (/Users/ug/git/tmp5/ionic-starter-nabto/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 6.5.0 

local packages:

    @ionic/app-scripts : 3.0.0
    Cordova Platforms  : ios 4.5.4
    Ionic Framework    : ionic-angular 3.7.1

System:

    Android SDK Tools : 26.0.2
    ios-deploy        : 1.9.2 
    ios-sim           : 6.1.2 
    Node              : v8.9.1
    npm               : 5.6.0 
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b 

Environment Variables:

    ANDROID_HOME : /Users/ug/Library/Android/sdk

Misc:

    backend : pro
guibson91 commented 5 years ago

@saarmic dis you tried what I suggested? update npm both globally and non globally:

npm install -g npm@latest and npm install npm@latest

I was stucked on that same problem during hours... I wasn't able to download the cordova-ios as well. I (suppose to) had the last version of npm, but kept telling me that it was 2.15.12. Upgrading the both solved it for me.

This resolved my problem!! Thanks!!