我尝试通过nat-upnp模块在node-webkit中upnp。我可以在Node.js控制台中使用nat-upnp。但是在node-webkit中,发生了未捕获的错误。
编码,
var express = require("express")
, app = express()
, fs = require('fs')
, natUpnp = require('nat-upnp')
, client = natUpnp.createClient()
;
//This function is to Map port
function startMap(){
client.portMapping({
public: 12345,
private: 8080,
ttl: 10
}, function(err) {
console.log(err)
//if err,try again.
startMap()
});
}
startMap()
//Video server
app.get('/', function(req, res){
stream = fs.createReadStream('output.mp4')
res.setHeader('Content-Type', 'video/mp4');
stream.pipe(res)
});
错误,
[49589:0213/054956:INFO:CONSOLE(79)] "Uncaught Error:
dlopen(/Users/endotakashi/bin/chips/node_modules/nat-upnp/node_modules/netroute/build/Release/netroute.node, 1):
no suitable image found. Did find:
环境,
OS X 10.9.1
Node v0.8.26
node-webkit v0.8.4
答案 0 :(得分:0)
您使用的是原生模块吗?应使用nw-gyp编译本机模块以使用node-webkit:
https://github.com/rogerwang/node-webkit/wiki/Build-native-modules-with-nw-gyp