0

I am studying node and socket.io but I got a problem in install socket.io Here's what I did:

  1. I created a folder named it as nodejs
  2. I created a app.js (no code inside yet)
  3. Tried to install the socket using this command `npm install socket.io

And I got these error messages:

C:\wamp\www\nodejs
λ npm install socket.io
/


> bufferutil@1.1.0 install C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild

|
C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil {git}{hg}
{lamb} node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
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:103:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11
gyp ERR! stack     at Object.oncomplete (evalmachine.<anonymous>:108:15)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil
gyp ERR! node -v v0.10.35
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing bufferutil@1.1.0

> utf-8-validate@1.1.0 install C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild


C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate {git}{hg}
{lamb} node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11
gyp ERR! stack     at Object.oncomplete (evalmachine.<anonymous>:108:15)
 ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
cwd C:\wamp\www\nodejs\node_modules\socket.io\node_modules\engine.io\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.10.35
ERR! node-gyp -v v1.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing utf-8-validate@1.1.0
\


> utf-8-validate@1.1.0 install C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild

|
C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate {git}{hg}
{lamb} node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
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:103:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11
gyp ERR! stack     at Object.oncomplete (evalmachine.<anonymous>:108:15)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.10.35
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing utf-8-validate@1.1.0

> bufferutil@1.1.0 install C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild


C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil {git}{hg}
{lamb} node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
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:103:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11
gyp ERR! stack     at Object.oncomplete (evalmachine.<anonymous>:108:15)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\wamp\www\nodejs\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil
gyp ERR! node -v v0.10.35
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing bufferutil@1.1.0
socket.io@1.3.6 node_modules\socket.io
├── has-binary-data@0.1.3 (isarray@0.0.1)
├── debug@2.1.0 (ms@0.6.2)
├── socket.io-parser@2.2.4 (isarray@0.0.1, component-emitter@1.1.2, debug@0.7.4, json3@3.2.6, benchmark@1.0.0)
├── socket.io-adapter@0.3.1 (object-keys@1.0.1, debug@1.0.2, socket.io-parser@2.2.2)
├── engine.io@1.5.2 (base64id@0.1.0, debug@1.0.3, engine.io-parser@1.2.1, ws@0.7.2)
└── socket.io-client@1.3.6 (component-bind@1.0.0, to-array@0.1.3, indexof@0.0.1, backo2@1.0.2, object-component@0.0.3, debug@0.7.4, component-emitter@1.1.2, has-binary@0.1.6, parseuri@0.0.2, engine.io-client@1.5.2)

When I checked my folder there's a node_modules folder and inside that is the socket.io. It seems ok but but can you tell me how did I got those errors? Do I need to reinstall nodejs? Or I missed some parts in installing socket?

Jerielle
  • 7,144
  • 29
  • 98
  • 164
  • 2
    See duplicate of [NPM - Can't install socket.IO](http://stackoverflow.com/questions/16469086/npm-cant-install-socket-io) for details. Installing socket.io involves some "build" steps that require certain tools be present beyond just npm. In this case, you need the appropriate version of Python installed and in your path and since you are on Windows, you will also need some C++ build tools. Details of installing all this on Windows are on the web (I will see if I can find an appropriate link). – jfriend00 Sep 18 '15 at 23:35
  • It should be noted that the `npm install socket.io` was successful here (you can see the module tree at the end of the output) and that the addon dependencies (`utf-8-validate` and `bufferutil`) are optional and socket.io will function just fine without them. It's purely a performance benefit to have those addons. – mscdex Sep 19 '15 at 03:47

3 Answers3

2

Socket.io was installed correctly.

What was not installed correctly were some optional dependencies.

npm WARN optional dep failed, continuing ...

And the reason why some deps were not installed correctly are pretty clear

gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

So you have to install python in your system if you want those optional dependencies installed (which you might want).

DevAlien
  • 2,456
  • 15
  • 17
2

Install python 2.7 and run

npm config set python C:\Python27\python.exe --global

References: https://www.robertkehoe.com/2015/03/fix-node-gyp-rebuild-error-on-windows/

shan1024
  • 1,389
  • 7
  • 17
1

stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

Make sure you have Python installed and set environment variable pointing to install location.

Rafal Wiliński
  • 2,240
  • 1
  • 21
  • 26