µWebSockets 编译失败,没有预编译的二进制文件
Compilation of µWebSockets has failed and there is no pre-compiled binary
我正在尝试 运行 使用 nodejs 的本地 websocket 服务器和 linux 机器上的 uws。 npm install uws
运行s 没有任何错误,我可以在我的 node_modules
中看到一个名为 uws 的文件夹。但是当我尝试使用以下代码创建 websocket 服务器时。它给我错误
/home/suresh/browserstack/node_modules/uws/uws.js:40
throw new Error('Compilation of µWebSockets has failed and there is no pre-compiled binary ' +
^
Error: Compilation of µWebSockets has failed and there is no pre-compiled binary available for your system. Please install a supported C++11 compiler and reinstall the module 'uws'.
at e (/home/suresh/browserstack/node_modules/uws/uws.js:40:19)
at Object.<anonymous> (/home/suresh/browserstack/node_modules/uws/uws.js:44:3)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/suresh/browserstack/ws/index.js:1:95)
这是我的js代码:
const WebSocket = require('uws').Server;
var http = require('http');
var server = http.createServer(function(request, response) {});
var wss = new WebSocket({
server: server,
path: '/wss'
});
var connCounter = 1;
wss.on('connection', function(ws){
console.log('new connection');
ws.id = connCounter;
ws.on('message', function(message){
});
ws.on('close', clearWS);
ws.on('end', clearWS);
ws.on('disconnect', clearWS);
ws.on('error', clearWS);
function clearWS(e){
console.log('in clearWS', e);
}
})
function sendBuffer(ws, buffer){
if (ws && ws.readyState == 1)
ws.send(buffer);
}
我查看了 /home/suresh/browserstack/node_modules/uws/uws.js:40
,发现本机函数由于缺少 uws_linux_48
文件而失败。下面是添加的打印错误日志语句:
Error: Cannot find module './uws_linux_48'
at Function.Module._resolveFilename (module.js:476:15)
at Function.Module._load (module.js:424:25)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at e (/home/suresh/browserstack/node_modules/uws/uws.js:29:20)
at Object.<anonymous> (/home/suresh/browserstack/node_modules/uws/uws.js:45:3)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12) code: 'MODULE_NOT_FOUND' }
我在互联网上搜索并发现了一些 github 问题和评论,但它们没有帮助。
这是我的系统信息:
gcc - version 5.5.0
node - v6.14.3
npm - 3.10.10
非常感谢
使用 PPA 在 Ubuntu 上安装最新的 nodejs
和 npm
,解决了这个问题。
早期版本
node - v6.14.3
npm - 3.10.10
最新版本解决了问题-
node - v10.6.0
npm - 6.1.0
参考 - How to Install Latest Node.js and NPM on Ubuntu with PPA
我正在尝试 运行 使用 nodejs 的本地 websocket 服务器和 linux 机器上的 uws。 npm install uws
运行s 没有任何错误,我可以在我的 node_modules
中看到一个名为 uws 的文件夹。但是当我尝试使用以下代码创建 websocket 服务器时。它给我错误
/home/suresh/browserstack/node_modules/uws/uws.js:40
throw new Error('Compilation of µWebSockets has failed and there is no pre-compiled binary ' +
^
Error: Compilation of µWebSockets has failed and there is no pre-compiled binary available for your system. Please install a supported C++11 compiler and reinstall the module 'uws'.
at e (/home/suresh/browserstack/node_modules/uws/uws.js:40:19)
at Object.<anonymous> (/home/suresh/browserstack/node_modules/uws/uws.js:44:3)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/suresh/browserstack/ws/index.js:1:95)
这是我的js代码:
const WebSocket = require('uws').Server;
var http = require('http');
var server = http.createServer(function(request, response) {});
var wss = new WebSocket({
server: server,
path: '/wss'
});
var connCounter = 1;
wss.on('connection', function(ws){
console.log('new connection');
ws.id = connCounter;
ws.on('message', function(message){
});
ws.on('close', clearWS);
ws.on('end', clearWS);
ws.on('disconnect', clearWS);
ws.on('error', clearWS);
function clearWS(e){
console.log('in clearWS', e);
}
})
function sendBuffer(ws, buffer){
if (ws && ws.readyState == 1)
ws.send(buffer);
}
我查看了 /home/suresh/browserstack/node_modules/uws/uws.js:40
,发现本机函数由于缺少 uws_linux_48
文件而失败。下面是添加的打印错误日志语句:
Error: Cannot find module './uws_linux_48'
at Function.Module._resolveFilename (module.js:476:15)
at Function.Module._load (module.js:424:25)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at e (/home/suresh/browserstack/node_modules/uws/uws.js:29:20)
at Object.<anonymous> (/home/suresh/browserstack/node_modules/uws/uws.js:45:3)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12) code: 'MODULE_NOT_FOUND' }
我在互联网上搜索并发现了一些 github 问题和评论,但它们没有帮助。
这是我的系统信息:
gcc - version 5.5.0
node - v6.14.3
npm - 3.10.10
非常感谢
使用 PPA 在 Ubuntu 上安装最新的 nodejs
和 npm
,解决了这个问题。
早期版本
node - v6.14.3
npm - 3.10.10
最新版本解决了问题-
node - v10.6.0
npm - 6.1.0
参考 - How to Install Latest Node.js and NPM on Ubuntu with PPA