- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将我的 Android 项目与 Leap 运动 Controller 连接,并使用 this question 中提到的过程和源代码。作为引用。
我对 Node.js 非常陌生,无法让 JavaScript 文件与 Node 一起使用,也无法解决依赖关系。我尝试了 Node 更新
,但没有成功。我需要解决以下错误:
$ node index.js
module.js:338
throw err;
^
Error: Cannot find module 'sleep'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/shivin/Development/LeapJS code/LeapMotionAndroidBridge/WebContent/index.js:11:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
这是供引用的 JavaScript 文件:
var http = require('http'), express = require('express'), app = express(), server = http
.createServer(app), port = process.env.PORT || 5000, position = {
x : 0,
y : 0,
z : 0,
hand : '',
present : false
};
var updated = false;
var sleep = require('sleep');
server.listen(port, function() {
console.log('Listening on ' + port);
});
function hasUpdate() {
if (updated) {
updated = false;
return true;
}
return false;
}
var BinaryServer = require('binaryjs').BinaryServer;
var binaryServer = new BinaryServer({
port : 9000
});
binaryServer.on('connection', function(client) {
console.log('accept binary connection');
var stream = client.createStream();
var buffer = [];
console.log('got stream');
stream.on('data', function(data) {
buffer.push(data);
var text = buffer.join();
var end = text.lastIndexOf('}');
if (end > -1) {
var temp = text.substr(0, end+1);
var start = temp.lastIndexOf('{');
if (start > -1) {
var message = text.substr(start, end+1);
var o=JSON.parse(message);
updateHandPosition(o);
if (end +1 < buffer.length) {
buffer = buffer.splice(end + 1, buffer.length);
}else{
buffer=[];
}
}
// console.log('received data from client ' + message + ' ' + end
// + ' ' + start + ' ');
}
});
});
app.use(express.bodyParser());
app.get('/', function(request, response) {
response.sendfile('public/index.html');
});
function updateHandPosition(o){
position.present = o.present;
if (position.present) {
position.x = o.x;
position.y = o.y;
position.z = o.z;
position.hand = o.hand;
} else {
position.x = null;
position.y = null;
position.z = null;
position.hand = null;
}
updated=true;
// console.log('updating hand position '+JSON.stringify(position));
}
app.post('/update', function(request, response) {
updateHandPosition(response.body);
response.json({
success : true
});
updated = true;
});
app.get('/retrieve', function(request, response) {
response.json(getPositionData());
});
function getPositionData() {
if (position.present) {
return {
present : true,
x : position.x,
y : position.y,
z : position.z,
hand : position.hand
};
} else {
return {
present : false
};
}
}
function forever(request, response) {
this.response = response;
this.request = request;
var ref = this;
this.request.on('close', function() {
ref.clear();
});
this.request.on('end', function() {
ref.clear();
});
};
forever.prototype.clear = function() {
this.request = null;
this.response = null;
};
forever.prototype.stream = function() {
if (this.response != null) {
if (hasUpdate()) {
this.response.write(JSON.stringify(getPositionData()));
this.response.write(",");
}
var ref = this;
setTimeout(function() {
ref.stream();
}, 5);
}
};
app.get('/stream', function(request, response) {
var f = new forever(request, response);
f.stream();
});
app.get(/^(.+)$/, function(req, res) {
res.sendfile('public/' + req.params[0]);
});
我尝试使用“node install sleep”,但收到以下错误日志:
npm WARN package.json LeapCallController@0.1.0 No repository field.
/
> sleep@2.0.0 install /home/shivin/Development/LeapJS code/LeapMotionAndroidBridge/WebContent/node_modules/sleep
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:66:16)
gyp ERR! stack at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:66:37)
gyp ERR! stack at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:152:20)
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:95:9
gyp ERR! stack at ChildProcess.exithandler (child_process.js:723:7)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at maybeClose (child_process.js:1000:16)
gyp ERR! stack at Socket.<anonymous> (child_process.js:1168:11)
gyp ERR! stack at Socket.emit (events.js:107:17)
gyp ERR! stack at Pipe.close (net.js:461:12)
gyp ERR! System Linux 3.16.0-30-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/shivin/Development/LeapJS code/LeapMotionAndroidBridge/WebContent/node_modules/sleep
gyp ERR! node -v v0.13.0-pre
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
npm ERR! sleep@2.0.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sleep@2.0.0 install script.
npm ERR! This is most likely a problem with the sleep package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls sleep
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.16.0-30-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "sleep"
npm ERR! cwd /home/shivin/Development/LeapJS code/LeapMotionAndroidBridge/WebContent
npm ERR! node -v v0.13.0-pre
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
最佳答案
如果您不使用 sleep ,请删除此行
var sleep = require('sleep');
或使用安装 sleep 模块
npm install sleep
并重新启动 Node 项目
关于javascript - 无法找到带有 Leap 运动的模块 "sleep",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28703218/
我通过 spring ioc 编写了一些 Rest 应用程序。但我无法解决这个问题。这是我的异常(exception): org.springframework.beans.factory.BeanC
我对 TestNG、Spring 框架等完全陌生,我正在尝试使用注释 @Value通过 @Configuration 访问配置文件注释。 我在这里想要实现的目标是让控制台从配置文件中写出“hi”,通过
为此工作了几个小时。我完全被难住了。 这是 CS113 的实验室。 如果用户在程序(二进制计算器)结束时选择继续,我们需要使用 goto 语句来到达程序的顶部。 但是,我们还需要释放所有分配的内存。
我正在尝试使用 ffmpeg 库构建一个小的 C 程序。但是我什至无法使用 avformat_open_input() 打开音频文件设置检查错误代码的函数后,我得到以下输出: Error code:
使用 Spring Initializer 创建一个简单的 Spring boot。我只在可用选项下选择 DevTools。 创建项目后,无需对其进行任何更改,即可正常运行程序。 现在,当我尝试在项目
所以我只是在 Mac OS X 中通过 brew 安装了 qt。但是它无法链接它。当我尝试运行 brew link qt 或 brew link --overwrite qt 我得到以下信息: ton
我在提交和 pull 时遇到了问题:在提交的 IDE 中,我看到: warning not all local changes may be shown due to an error: unable
我跑 man gcc | grep "-L" 我明白了 Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more inf
我有一段代码,旨在接收任何 URL 并将其从网络上撕下来。到目前为止,它运行良好,直到有人给了它这个 URL: http://www.aspensurgical.com/static/images/a
在过去的 5 个小时里,我一直在尝试在我的服务器上设置 WireGuard,但在完成所有设置后,我无法 ping IP 或解析域。 下面是服务器配置 [Interface] Address = 10.
我正在尝试在 GitLab 中 fork 我的一个私有(private)项目,但是当我按下 fork 按钮时,我会收到以下信息: No available namespaces to fork the
我这里遇到了一些问题。我是 node.js 和 Rest API 的新手,但我正在尝试自学。我制作了 REST API,使用 MongoDB 与我的数据库进行通信,我使用 Postman 来测试我的路
下面的代码在控制台中给出以下消息: Uncaught DOMException: Failed to execute 'appendChild' on 'Node': The new child el
我正在尝试调用一个新端点来显示数据,我意识到在上一组有效的数据中,它在数据周围用一对额外的“[]”括号进行控制台,我认为这就是问题是,而新端点不会以我使用数据的方式产生它! 这是 NgFor 失败的原
我正在尝试将我的 Symfony2 应用程序部署到我的 Azure Web 应用程序,但遇到了一些麻烦。 推送到远程时,我在终端中收到以下消息 remote: Updating branch 'mas
Minikube已启动并正在运行,没有任何错误,但是我无法 curl IP。我在这里遵循:https://docs.traefik.io/user-guide/kubernetes/,似乎没有提到关闭
每当我尝试docker组成任何项目时,都会出现以下错误。 我尝试过有和没有sudo 我在这台机器上只有这个问题。我可以在Mac和Amazon WorkSpace上运行相同的容器。 (myslabs)
我正在尝试 pip install stanza 并收到此消息: ERROR: No matching distribution found for torch>=1.3.0 (from stanza
DNS 解析看起来不错,但我无法 ping 我的服务。可能是什么原因? 来自集群中的另一个 Pod: $ ping backend PING backend.default.svc.cluster.l
我正在使用Hibernate 4 + Spring MVC 4当我开始 Apache Tomcat Server 8我收到此错误: Error creating bean with name 'wel
我是一名优秀的程序员,十分优秀!