前端开发 2755



Building for node-webkit

Because of ABI differences, sqlite3 must be built in a custom to be used with node-webkit.

To build node-sqlite3 for node-webkit:

Install nw-gyp globally: npm install nw-gyp -g (unless already installed)

Build the module with the custom flags of --runtime, --target_arch, and --target:

NODE_WEBKIT_VERSION="0.8.6" # see latest version at https://github.com/rogerwang/node-webkit#downloads npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION) This command internally calls out to node-pre-gyp which itself calls out to nw-gyp when the --runtime=node-webkit option is passed.

You can also run this command from within a node-sqlite3 checkout:

npm install --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION) Remember the following:

You must provide the right --target_arch flag. ia32 is needed to target 32bit node-webkit builds, while x64 will target 64bit node-webkit builds (if available for your platform).

After the sqlite3 package is built for node-webkit it cannot run in the vanilla Node.js (and vice versa).

For example, npm test of the node-webkit's package would fail. Visit the “Using Node modules” article in the node-webkit's wiki for more details.

cd node_modules/sqlite3

npm run prepublish # 检查依赖 缺少nan包 安装 npm install nan --save

需要安装 node-gyp 并查看 electron -v 版本

node-gyp configure --module_name=node_sqlite3 --module_path=../lib/binding/electron-v1.2-darwin-x64

node-gyp rebuild --target=1.2.7 --arch=x64 --target_platform=darwin --dist-url=https://atom.io/download/atom-shell --module_name=node_sqlite3 --module_path=../lib/binding/electron-v1.2-darwin-x64