Air off, Mind on ~ / Javascript+Golang, Sci, Health… /

Start a NodeJS Addon Under Windows

Code & tools preparation

NodeJS source code https://github.com/joyent/node

VISUAL C++ 2010 EXPRESS Free tools to create applications on Windows using Visual C++. (Needs SP3 under winxp)

Download VC++ 2010 EXPRESS

Python 2.6 or 2.7 http://www.python.org/download/

Compile your NodeJS

Run vcbuild.bat under NodeJS source folder.

Compile the Hello-world

General Steps also fit for other addons

Get into folder test\addons\hello-world\ of NodeJS source

1, Edit binding.cc

Add NODE_MODULE_EXPORT before void init or Add NODE_EXTERN between void and init

This could help avoid running “Unkown error” when require the addon in nodejs.

2, Generate project files

set NODE_ROOT=your-node-js-src-root 
python %NODE_ROOT%\tools\gyp_addon binding.gyp

3, Setup VC ENV variables


"D:\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"

4, Build

@set Configuration=Release

5, Test


Compile node-expat

  1. Install Expat under windows http://sourceforge.net/projects/expat/files/latest/download

  2. Prepare GYP build file

    { ‘targets’: [ { ‘target_name’: ‘node-expat’, ‘sources’: [ ‘node-expat.cc’ ], ‘include_dirs’: [ ‘expat-install-folder/Source/lib’ ], ‘libraries’: [ ‘-lexpat-install-folder/Bin/libexpat.lib’ ], } ] }

A more detail guide could be found in another post: Build Node-Expat Under Windows

Compile node-xmpp

  1. ICU unicode http://site.icu-project.org/download/48

  2. node-stringprep windows version https://github.com/andreasbotsikas/node-stringprep/tree/windows-build

  3. node-xmpp