Zhongde Liu

This is my personal "Clipboard" of web development stuff I come across

Leave a comment

npm, node-gyp error and Windows

I wanted to try out the Sails framework. On installation (npm install sails) however I just got this error and the installation was unsuccessful.

npm ERR! ws@0.4.32 install: `(node-gyp rebuild 2> builderror.log) || (exit 0)`
npm ERR! spawn ENOENT

It is the same thing as in this closed issue on github. There was a reference to a buggy version of ws/socketIO. Googling some more you get a lot issues related to socketIO and Windows7 or this topic in general. For example:  https://github.com/websockets/ws/issues/240 or http://stackoverflow.com/questions/15200184/why-do-i-get-error-when-trying-to-install-socket-io-with-nmp

In fact as a windows(7) user you may stumbled upon these node-gyp error previously…. nody-gyp is used “for compiling native addon modules for Node.js”. Unfortunately the prerequisites on Windows are Python and Visual Studio!?. Including also several steps for a working setup… https://github.com/TooTallNate/node-gyp/wiki/Visual-Studio-2010-Setup.

I thought  “What the …”. I just wanted to try something out.

End of story: I used “–force” on the install command and it worked. But for how long and what actually happened or did not happen behind the installation curtain!? I hope node-gyp, or the related modules (ws) will get updates to fix these hurdles on windows machines…


Update: As of now Sails(0.11.0) and socketIO(1.3.5) are installing just fine on windows…


Create/start a simple local HTTP Server

In order to develop or test some static code, without copying them into your apache webroot or something else, you easily can start a simple static webserver within the directory you are currently in with following tools.
Because you sometimes you just need a http:// (likely localhost) Url instead of a file://… one.

  1. If you have Python (https://www.python.org/) installed you can start a static web server with following command, depending on the installed version.
    python -m SimpleHTTPServer [port]//python2
    python3 -m http.server [port]//python3
  2. If you have PHP > 5.4.0 (http://php.net/) installed you can start one with:
    php -S localhost:[port]
  3. Using Ruby (https://www.ruby-lang.org/) you setup a simple server with this command:
    ruby -run -e httpd . -p [port]
  4. For node.js (http://nodejs.org/) I use the  “simple, zero-configuration command-line http server” package (https://www.npmjs.org/package/http-server).
    After the default npm installation

    npm install http-server -g

    you just type

    http-server -p[port]

    into your console.

These are some nifty tools (or “oneliners“), when it comes to browse a static/client app/website/file with your browser in your local environment without copying the files somewhere else.

Leave a comment

How-to: Proxy setting for “Github for Windows”

For setting the proxy you need to edit a file named .gitconfig. This file should be located in your user folder, C:\Users\[xxxxx]\.gitconfig with [xxxxx] being your windows username.

In this file you need to add following lines, adapted to your proxy:

proxy = http://proxy.example.com:8080 

proxy = http://proxy.example.com:8080

1 Comment

HTML5 Video Encoding – Codecs

There is no single combination of containers and codecs that works in all HTML5 browsers.

For maximum compatibility you need more than one version:

Container: WebM
Video-Codec: VP8
Audio-Codec: Vorbis

Container: Ogg
Video: Theora
Audio: Vorbis

Container: MP4
Video: H.264 baseline-profile
Audio: AAC (low complexity)

For MP4 Mobile pay attention to possible  max-resolutions on the different devices:
480×320 (base), 640×480 (no older androids, blackberrys) or more e.g. 1280×720 (only ‘new’ devices)…


More Info and references:




Frameworks/Libs for HTML5 implementation:




How-To: npm behind a proxy

When you want to use npm (http://npmjs.org/), package manager for node, behind a proxy, pay attention that there are two parameters for setting up a proxy:

  1. proxy
  2. https-proxy

As https is the default protocol for fetching the packages from the npm repository you must set the second one.

Another workaround is to change the rep url into a http one.