Tag: 运行时错误

Node.js错误Arduino串行监视器input

请帮助新手出去。 我试图学习Node.js,尝试通过串口连接一个正常工作的Arduino示例。 代码如下: var serialport = require("serialport"); // include the serialport library var SerialPort = serialport.SerialPort; // localize object constructor var express = require('express'), app = express() , http = require('http') , server = http.createServer(app) , io = require('socket.io').listen(server); // listen for new web clients: server.listen(8080); // open the serial port. Change the name to […]

RethinkDB抛出错误,而不是在callback中返回它们

Nodejs的情况: r.db('users').get('e@mai.l').without(['password']).run() 如果用户不存在rethinkdb将会抛出一个错误 — 2014-01-22T13:26:04.720Z [20163] [ ctx error ] — RqlRuntimeError: Cannot perform without on a non-object non-sequence `null`. in: r.table('users').get('e@mai.l').without(['password']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 问题: 为什么Rethink会抛出错误而不是在callback的第一个参数中返回? 为什么它会抛出错误呢? 不能它只是最后返回null,完成请求?

Nodejs有什么问题?

我正在使用Muller来处理上传图片。 app.use(multer({ dest: './public/photos', rename: function (fieldname, filename) { return filename+Date.now(); }, onFileUploadStart: function (file) { console.log(file.originalname + ' is starting …') }, onFileUploadComplete: function (file) { console.log(file.fieldname + ' uploaded to ' + file.path) //a='asass'; done=true; } })); app.post('/api/photo',function(req,res){ if(done==true){ //ERROR here if I remove comment on 'a=asass' >> 'done' is not defined console.log(req.files); […]

错误消息显示意外的尖括号,但应该没有意想不到的尖括号

我写了一些代码,我从我的节点服务器node.js 。 我已经得到了HTML服务,但是当我开始向index.html文件添加脚本时,我发现在开发者控制台中出现了最奇怪的错误: Uncaught SyntaxError: Unexpected token < jquery-1.12.4.min.js:1 Uncaught SyntaxError: Unexpected token < hack.js:1 这是我的HTML: <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type="text/css" href="hack.css"> </head> <body> <h1>Colour Hack v1.0</h1> <p>Guess the correct values for each colour to unlock information on the European Union.</p> <script src="jquery-1.12.4.min.js"></script> <script src="hack.js"></script> </body> </html> hack.js代码: const box = "<canvas>BOX</canvas>" $(document).ready(function() […]

即使被拒绝的承诺被处理,也会收到`UnhandledPromiseRejectionWarning`

我已经构build了一个函数,它遍历一个包含同步代码和Promises的Generator : module.exports = { isPromise (value) { return typeof value === 'object' && value !== null && 'then' in value; }, runGen (generatorFunc, startValue) { let that = this, i = 0; function *iterator(resolve, reject) { let runGeneratorFunc = generatorFunc(startValue), yieldedOut = {done: false}, yieldIn; while (!yieldedOut.done) { console.log(i++, 'Ready for next iteration'); if […]

节点 – 骑手未处理的拒绝评估

我正在尝试用Node-horseman编写一个基本的网页抓取工具,但是我在评估函数中遇到了CSSselect器的一些问题。 有些网站的评估函数工作得很好,但是对于其他的网站,Node会抛出一个错误。 例如: var Horseman = require('node-horseman'); var horseman = new Horseman(); function getTitle() { var title = $('.product-name-main h1').text(); return {title: title}; } horseman .userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0') .open('http://shtoraoptom.ru/pokryvalo-nazsu-gul-abrikosovyj-240-260-sm') .evaluate(getTitle) .then(function(title){ console.log(title); return horseman.close(); }); 这段代码会抛出一个错误: Unhandled rejection getTitle evaluate global code evaluateJavaScript@[native code] evaluate@phantomjs://platform/webpage.js:390:39 phantomjs://code/bridge.js:121:61 at Horseman.<anonymous> (/home/ubuntu/workspace/node_modules/node-horseman/lib/actions.js:839:38) at […]

nodejs module.js:340 throw err; 使用WebSocket-Node

即时通讯新的这一点,我安装在Windows安装程序的nodejs。 然后我用这个命令安装了WebSocket-Node模块:npm install websocket,看起来像成功安装。 npm http GET https://registry.npmjs.org/websocket npm http 200 https://registry.npmjs.org/websocket npm http GET https://registry.npmjs.org/websocket/-/websocket-1.0.8.tgz npm http 200 https://registry.npmjs.org/websocket/-/websocket-1.0.8.tgz > websocket@1.0.8 install D:\dev\html5\books\bumper\node_modules\websocket > node install.js [websocket v1.0.8] Attempting to compile native extensions. [websocket v1.0.8] Native extension compilation successful! websocket@1.0.8 node_modules\websocket 它在这个位置安装了nodejs: c:\ Program Files(x86)\ nodejs \ 现在我尝试从https://github.com/Worlize/WebSocket-Node执行server.js例子,我得到这个错误: D:\dev\html5\books\bumper>node server.js module.js:340 throw err; ^ […]

请求总是返回空错误对象

我使用Request和标准的Node.js HTTP模块来编写一个简单的rest服务。 现在,服务器端请求处理程序如下所示: response.writeHead("400","Nope"); response.end(); 客户端代码如下所示: request.get(href,handleResponse); function handleResponse(error,response,body) { console.log(arguments); } response.statusCode是400 ,但error始终为null 。 我需要做什么服务器端获取请求模块来识别响应是一个错误?

在WebMatrix中运行节点应用程序时出错

我安装了WebMatrix并按照这些说明在我的Windows 7机器上安装了IIS 7。 当我点击“运行”运行我的快递节点的应用程序,浏览器popup并告诉我 iisnode模块无法启动node.exe进程。 确保node.exe可执行文件在web.config的system.webServer/iisnode/@nodeProcessCommandLine元素中指定的位置可用。 默认情况下,node.exe预计将安装在x86系统上的%ProgramFiles%\ nodejs文件夹和x64系统上的%ProgramFiles(x86)%\ nodejs文件夹中。 这是我的web.config: <configuration> <system.webServer> <handlers> <!– indicates that the app.js file is a node.js application to be handled by the iisnode module –> <add name="iisnode" path="app.js" verb="*" modules="iisnode" /> </handlers> <rewrite> <rules> <!– Don't interfere with requests for logs –> <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true"> <match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$" /> […]