]> khamidou — GitHub mirrors - electron.git/commitdiff
:memo: Say some more about native node modules.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 30 Apr 2014 07:03:14 +0000 (15:03 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 30 Apr 2014 07:03:14 +0000 (15:03 +0800)
docs/tutorial/use-native-node-module.md

index 7caed97cf11d0253c5e084c54d9eedb01eab5f16..41e1ef433424ab189438eb2b747be80e8f9da295 100644 (file)
@@ -1,10 +1,11 @@
 # Use native node modules
 
-Since atom-shell is using a different V8 version from the official node, you
-need to build native module against atom-shell's headers to use them.
+The native node modules are supported by atom-shell, but since atom-shell is
+using a different V8 version from official node, you need to use `apm` instead
+of `npm` to install node modules.
 
-The [apm](https://github.com/atom/apm) provided a easy way to do this, after
-installing it you could use it to install dependencies just like using `npm`:
+The usage of [apm](https://github.com/atom/apm) is quite similar to `npm`, to
+install dependencies from `package.json` of current project, just do:
 
 ```bash
 $ cd /path/to/atom-shell/project/
@@ -12,12 +13,25 @@ $ apm install .
 ```
 
 But you should notice that `apm install module` wont' work because it will
-install a user package for [Atom](https://github.com/atom/atom) instead.
+install a user package for [Atom Editor](https://github.com/atom/atom) instead.
+
+## Native node module compability
+
+Since node v0.11.x, there were vital changes of V8 API, so generally all native
+modules written for node v0.10.x wouldn't work for node v0.11.x, and since
+atom-shell internally uses node v0.11.9, it carries with the same problem.
+
+To solve it, you should use modules that support both node v0.10.x and v0.11.x,
+and [many modules](https://www.npmjs.org/browse/depended/nan) do support the
+both now. For old modules that only support node v0.10.x, you should use the
+[nan](https://github.com/rvagg/nan) module to port it to v0.11.x.
+
+## Other ways of installing native modules
 
 Apart from `apm`, you can also use `node-gyp` and `npm` to manually build the
 native modules.
 
-## The node-gyp way
+### The node-gyp way
 
 First you need to check which node release atom-shell is carrying via
 `process.version` (at the time of writing it is v0.10.5), then you can
@@ -32,7 +46,7 @@ The `HOME=~/.atom-shell-gyp` changes where to find development headers. The
 `--target=0.10.5` is specifying node's version. The `--dist-url=...` specifies
 where to download the headers.
 
-## The npm way
+### The npm way
 
 ```bash
 export npm_config_disturl=https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist