Attempting to install Phonegap on your Ubuntu workstation? Well guess again. At the time of writing this post, users following the steps on the Phonegap website to install would receive version errors stating that the version of nodejs may be unsuitable.

Please note that this is not a tutorial, but merely an account of an issue I encountered when attempting to install PhoneGap.

The setup starts by installing nodejs and npm:

sudo apt-get install nodejs npm -y

Entering the following command, like on the Phonegap website, will present the user with the following error:

sudo npm install -g phonegap
npm http GET https://registry.npmjs.org/phonegap
npm http 200 https://registry.npmjs.org/phonegap

npm ERR! Error: No compatible version found: phonegap
npm ERR! No valid targets found.
npm ERR! Perhaps not compatible with your version of node?
npm ERR!     at installTargetsError (/usr/share/npm/lib/cache.js:488:10)
npm ERR!     at next_ (/usr/share/npm/lib/cache.js:438:17)
npm ERR!     at next (/usr/share/npm/lib/cache.js:415:44)
npm ERR!     at /usr/share/npm/lib/cache.js:408:5
npm ERR!     at saved (/usr/share/npm/lib/utils/npm-registry-client/get.js:147:7)
npm ERR!     at Object.oncomplete (/usr/lib/nodejs/graceful-fs.js:230:7)
npm ERR! You may report this log at:
npm ERR!     
npm ERR! or use
npm ERR!     reportbug --attach /var/www/dbwrap/npm-debug.log npm
npm ERR! 
npm ERR! System Linux 3.2.0-48-generic
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "phonegap"
npm ERR! cwd /var/www/dbwrap
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message No compatible version found: phonegap
npm ERR! message No valid targets found.
npm ERR! message Perhaps not compatible with your version of node?
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /var/www/dbwrap/npm-debug.log
npm not ok

Simply force the install by adding the f flag:

sudo npm install -gf phonegap

That should result in a successfully installed copy of Phonegap – Enjoy!

Join the conversation! 17 Comments

  1. no this error are coming at last time
    npm ERR! error installing winston@0.6.2
    npm http GET https://registry.npmjs.org/npm/-/npm-1.3.13.tgz
    npm ERR! error installing prompt@0.2.11
    npm ERR! error installing phonegap@3.1.0-0.15.0

    npm ERR! Error: failed to fetch from registry: stack-trace
    npm ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
    npm ERR! at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
    npm ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
    npm ERR! at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
    npm ERR! at Request. (/usr/lib/nodejs/request/main.js:212:58)
    npm ERR! at Request.emit (events.js:88:20)
    npm ERR! at ClientRequest. (/usr/lib/nodejs/request/main.js:209:10)
    npm ERR! at ClientRequest.emit (events.js:67:17)
    npm ERR! at CleartextStream. (http.js:1210:13)
    npm ERR! at CleartextStream.emit (events.js:88:20)
    npm ERR! You may report this log at:
    npm ERR!
    npm ERR! or use
    npm ERR! reportbug –attach /home/gdjkj/npm-debug.log npm
    npm ERR!
    npm ERR! System Linux 3.8.0-32-generic
    npm ERR! command “node” “/usr/bin/npm” “install” “-gf” “phonegap”
    npm ERR! cwd /home/gdjkj
    npm ERR! node -v v0.6.12
    npm ERR! npm -v 1.1.4
    npm ERR! message failed to fetch from registry: stack-trace
    npm ERR!
    npm ERR! Additional logging details can be found in:
    npm ERR! /home/gdjkj/npm-debug.log
    npm not ok

    Reply
  2. npm http 200 http://registry.npmjs.org/request
    npm ERR! failed to fetch http://registry.npmjs.org/mute-stream/-/mute-stream-0.0.4.tgz
    npm ERR! error installing read@1.0.5
    npm http GET http://registry.npmjs.org/request/-/request-2.11.4.tgz
    npm ERR! error installing prompt@0.2.11
    npm ERR! error installing phonegap@3.1.0-0.15.0

    npm ERR! Error: socket hang up
    npm ERR! at createHangUpError (http.js:1107:15)
    npm ERR! at Socket.onend (http.js:1188:27)
    npm ERR! at TCP.onread (net.js:369:26)
    npm ERR! You may report this log at:
    npm ERR!
    npm ERR! or use
    npm ERR! reportbug –attach /home/gdjkj/npm-debug.log npm
    npm ERR!
    npm ERR! System Linux 3.8.0-33-generic
    npm ERR! command “node” “/usr/bin/npm” “install” “-gf” “phonegap”
    npm ERR! cwd /home/gdjkj
    npm ERR! node -v v0.6.12
    npm ERR! npm -v 1.1.4
    npm ERR! code ECONNRESET
    npm ERR! message socket hang up
    npm ERR! errno {}
    npm ERR!
    npm ERR! Additional logging details can be found in:
    npm ERR! /home/gdjkj/npm-debug.log
    npm not ok

    Reply
    • Hi Ajay, I’m afraid I don’t know what’s causing your NodeJS errors, I didn’t run across such a problem when installing phonegap, and I’m still not terribly seasoned when it comes to NodeJS anyhow.

      Perhaps your issue is better suited for a forum, but if it were me I’d try a clean development environment, starting the installation from scratch (and following the instructions on the phonegap website). I wish you luck.

      Reply
  3. […] we install Cordova: On Ubuntu (we use the f(orce) flag due to an installation problem reported here: sudo npm install -gf […]

    Reply
  4. I had no problems installing phonegap.

    All nodejs problems usually arise from old node versions, so the first thing I do on Ubuntu 12.04 installations is this:
    https://gist.github.com/dirkk0/7416217

    Reply
    • Hi Dirk,

      I have no doubt that if it were indeed a widespread issue, that the Phonegap guys would have gotten around to fixing it (hopefully by now). I encountered the issue on a fresh install, with a brand new copy of Node.

      Your link is quite handy, cheers.

      Reply
  5. thanks for this hint!!

    Reply
  6. It was just the tip I needed for installing in Linux Mint 15 Matte – ta!

    Reply
    • Hi Stephane – That is obviously for Cordova and not Phonegap, but it covers a good point. They seem to uninstall Node before changing the repo and installing again – Which may only be relevant for some users, as the version of Node may not play too bigger a part in this problem. I would still advise trying with the -f flag first, and perhaps look at reinstalling a newer version of Node JS (as covered in Stephane’s link) if this doesn’t help. I would be interested to hear how successful just updating the version of node is in installing Phonegap like this.

      Thanks for the link.

      Reply
  7. I created a script (including the installation of the SDK tools and 4.4.2) that can run unattended. It installs Phonegap and dependencies in less than 5 minutes on a fresh Ubuntu 12.0.4:
    https://gist.github.com/dirkk0/8414616

    Reply
  8. Thanks Bro!!

    Reply

Leave a Reply

Category

Programming, Software

Tags

,