Error on "npm install socket.io"

I'm trying to update my socket.io version (current is 0.9.11), so I've edited the package.json file to:

{
  "name": "aaa",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "app.js"
  },
  "dependencies": {
    "express": "3.0.3",
    "hjs": "0.0.4",
    "cradle": "0.6.4",
    "socket.io": "0.9.14"
  },
  "subdomain": "aaa",
  "engines": {
    "node": "0.6.x"
  }
}

I'm getting that following weird error:

gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:113:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:81:11
gyp ERR! stack     at Object.oncomplete (fs.js:107:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\apps\sms - part 2\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws
gyp ERR! node -v v0.10.3
gyp ERR! node-gyp -v v0.9.5
gyp ERR! not ok 

So I have three questions:

  1. How did I manage to install socket.io before + run my node.js server successfully ?

  2. How is Python related to this ? I don't have Python on my PC and I didn't know I should have.

  3. How to solve this issue ?

EDITED Just forgot to mention that socket.io module doesn't get update and stays on 0.9.11 version

Python is required by node-gyp for compiling native addons.

An example of one is ws, which socket.io-client depends on:

cwd ...\node_modules\socket.io\node_modules\socket.io-client\node_modules\ws

And, the difference for why it installed before is likely within ws. The project had specified a "scripts": { "install": "..." } that would allow for failing to compile when installing. Both of these seem to have since (v0.4.19, at least) been removed.


One available fix is to install node-gyp's dependencies, including Python. This would probably be best as it allows you to keep up-to-date with bug fixes.

Another is to specify a lower version of ws, that's still compatible with socket.io-client's dependencies, by adding it to your package.json:

"dependencies": {
    "express": "3.0.3",
    "hjs": "0.0.4",
    "cradle": "0.6.4",
    "socket.io": "0.9.14",
    "ws": "0.4.19"
}