Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap installation error (npm)

I have been searching for a solution for two days now to setup Phonegap on my Windows 8.1 system without any success.

Whenever I try to install Phonegap through npm I get an error that I think has to do with Cordova(-lib).

To install Phonegap I had to install Node.js (v0.10.28) on my system. After this I opened up Windows Powershell and issued the following command like instructed on the Phonegap website:

npm install -g phonegap

Output: (This is the only part of the error)

error notarget No compatible version found: cordova-lib@'lorinbeer/cordova-lib.git#configparser_module'
error notarget Valid install targets:
error notarget ["0.21.2","0.21.3"]
error notarget
error notarget This is most likely not a problem with npm itself.
error notarget In most cases you or one of your dependencies are requesting
error notarget a package version that doesn't exist.

I also tried installing just Cordova through the npm and then install Phonegap, but that didn't solve anything either.

Running the Powershell with administrator rights also didn't help and tried solutions of other people who also had problems setting up Phonegap, but nothing works.

I really hope that someone could help me out here.

Thanks in advance.

like image 610
ihsan Avatar asked Jun 06 '14 14:06

ihsan


People also ask

How to install PhoneGap using npm?

We will run the $ npm install -g phonegap@latest command in the Terminal app (Mac) or Command Prompt (Win). We will install the PhoneGap CLI by using the npm package. We will execute the phonegap command on the command line to ensure that the PhoneGap CLI is properly installed or not.

What is the command to install PhoneGap?

PhoneGap and Cordova Install the plugin on the Settings/Preferences | Plugins page, tab Marketplace. PhoneGap and Apache Cordova are frameworks for developing mobile application with single HTML, CSS, and JavaScript/TypeScript code base and targeting various mobile platforms, including Android.

How install PhoneGap on Windows?

First of all to install PhoneGap, we need to write this command “npm install -g phonegap”. This will install PhoneGap, this may take a while for the install to be completed. Once PhoneGap is installed, create a folder for PhoneGap projects. In the command prompt, navigate to the newly created folder.


4 Answers

Download the older version. I think there was a problem in the new one

npm install -g [email protected]

I tried this and worked for me.

like image 194
arpan shah Avatar answered Oct 23 '22 12:10

arpan shah


I had the same issue yesterday. If you check npm-debug.log, you'll notice that there is a permission issue ("Permission denied") when npm tries to access the cordova-lib git repository url. Actually, cordova-lib is a dependency for phonegap. So, it can't install it and I think that's why you get that error.

So, I tried this: install cordova-lib first then Phonegap. Yet, it still won't work; npm does not seem to check if cordova-lib is installed before trying to do it. At this point, what I could do is to change the repository from which it retrieves cordova-lib. Here is the NPM install syntax:

npm install <tarball file>
npm install <tarball url>
npm install <folder>
npm install <pkg>
npm install <pkg>@<tag>
npm install <pkg>@<version>
npm install <pkg>@<version range>

This means I can install from a tar.gz file. Great! So, I just went to this page https://www.npmjs.org/package/phonegap to check the phonegap repository and performed these steps:

  1. Download the zip of phonegap-cli repo (https://github.com/phonegap/phonegap-cli/archive/master.zip)
  2. Unzip it
  3. Open the package.json file and find the cordova-lib entry in dependencies (line 32)
  4. Change the value to 0.21.3 which is the last version.
  5. Recreate an archive of the folder to the tar.gz format
  6. Open your CLI and run this command:

    npm install -g path/to/archive/phonegap-cli-master.tar.gz
    

It should work now.

Hope that help!

like image 44
UGasCamb Avatar answered Oct 23 '22 14:10

UGasCamb


I had a similar problem today too on Mac, even after Lorenzo said it should be all fine. Just running this:

sudo npm install -g phonegap

... produced loads of errors like this:

error: file ./objects/pack/pack-48c0ff4147fb7e8922546c4a857b98a1cb48e01f.pack is far too short to be a packfile

I combined Lorenzo and arpan shah's solutions:

sudo npm install -g [email protected]
sudo npm cache clean
sudo npm update -g phone gap

... and it seemed to magically work.

like image 4
Jamie Brown Avatar answered Oct 23 '22 13:10

Jamie Brown


Problem

We published with a dependency on a branch of cordova-lib. This fork appears unavailable when lots of requests are coming through (I think). One way or another, it's unreliable. Changing the dependency to 0.21.3 will cause commands to fail, but will allow the install.

Solutions

  1. update the 'cordova-lib' dependency to the npm published version '0.21.3' **note, this will allow the install, but other phonegap commands will fail

  2. wait for about 20 minutes, then npm update -g phonegap testing an update to resolve this issue

further updates momentarily

update We've pushed version 3.5.0-0.20.3 which should resolve this issue

$ npm update -g phonegap

if that doesn't work, try

$ npm cache clean

and reinstall phonegap

like image 2
Lorenzo Avatar answered Oct 23 '22 13:10

Lorenzo