1

我有一个要求,我必须访问 C 函数并将其公开为 API。我应该将它部署在 Node.js 服务器上。我不知道如何使用任何节点包访问 C 函数。我曾尝试使用node-ffi包,但在安装时它给了我错误:

gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: incorrect header check
gyp ERR! stack     at Zlib._binding.onerror (zlib.js:295:17)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\niket_kumar\AppData\Roaming\npm\node_modules\node-ffi
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

npm ERR! node-ffi@0.5.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-ffi@0.5.7 install script.

请注意,我使用的是 Python 2.7 和 Windows 7(32 位)。

4

1 回答 1

1

尝试使用这个包安装node-ffihttps ://www.npmjs.com/package/ffi 。请注意,它被称为ffi,而不是node-ffi

还要确保您拥有 Python 2.7.3 版本。node-gyp的 GitHub 页面提到 2.7.3 是 Windows 操作系统的推荐版本。

于 2015-04-14T17:11:45.643 回答