Tag: 语法错误

Node.js指示超出文件结尾的意外令牌

我在Node.js中开发一个非常简单的机器人,它不会再启动了。 Node.js表示一个意外的令牌错误,但列出的行号超过了文件的末尾。 具体来说,错误是: C:\Users\Owner\Bot\jovial_bot.js:294 }); ^ node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ SyntaxError: Unexpected token ) at Module._compile (module.js:427:25) at Object..js (module.js:450:10) at Module.load (module.js:351:31) at Function._load (module.js:310:12) at Array.0 (module.js:470:10) at EventEmitter._tickCallback (node.js:192:40) 程序的最后一行是} ); 但是,最后一行是行号293.在文件末尾添加换行符会增加Node.js报告的行号。 据我所知,我没有任何不配合的括号。 我尝试添加(到文件末尾,错误更改为“Unexpected token}”。添加“({”将错误更改为“意外的input结束”,我不知道该怎么办。你提前帮忙。 我的代码在这里: http : //jsfiddle.net/kunkelwe/VEBtH/而我正在使用这个API: https : //github.com/alaingilbert/Turntable-API/blob/master/turntable_data/deregistered.js

SQL node.js什么似乎是一个有效的查询语法错误?

我在桌子上运行更新以设置位置。 我解压查询并手动运行在我的数据库上,工作正常,但通过connection.query()传递时,似乎认为我的node.js控制台中有语法错误。 function sendShipPosition(position) { var input = ''; if (position.moving === true) { var currentdate = new Date(); var datetime = currentdate.getFullYear() + "-" + (currentdate.getMonth()+1) + "-" + currentdate.getDate() + " " + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds(); var input = ', moving_datetime = ' + datetime; } connection.query('UPDATE […]

节点callback中令人意外的令牌function

我对节点和callback是非常新的。 我正在处理Nodeschool问题:使用callback函数按顺序返回三个给定URL的数据。 我把这三个URL的结果放在一个对象中,以便跟踪它们。 但是,我一直在testing失败,因为我认为,在我把所有的URL放入它之前,URL对象被返回。 TLDR: 这是违规的function。 它一直告诉我“SyntaxError:意外的标记function”。 但是当我把console.log(urlObj[url])放到它自己的函数中,并在storeUrl通过名称调用它时,我不认为它是在if语句之后运行的。 function storeUrl(url, info, function(url) { // Only log after all the checking is done console.log(urlObj[url]); } ){ // add data to a dict? or something? // to keep track of them??? if(url == url1){ urlObj[url1] = info; } if(url == url2){ urlObj[url2] = info; } if(url == […]

在Linux上使用节点0.12.7获取“意外的保留字”

我在以下版本的Linux上使用节点0.12.7 … [davea@mydevbox Automate-04-01-2016]$ uname -a Linux mydevbox.evo-text.com 2.2.8-35.46.amzn1.x86_64 #1 SMP Wed Mar 16 17:15:34 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux 但是,当我尝试运行我的文件,我得到这个错误 [davea@mydevbox Automate-04-01-2016]$ node start.js Validation Complete /home/davea/node_modules/selenium-webdriver/index.js:25 const builder = require('./builder'); ^^^^^ SyntaxError: Use of const in strict mode. at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load […]

在node.js中发送HTTP响应

我正在尝试在节点中发送一个http响应,以在浏览器中打印结果。 简化的源代码如下。 基本上,所有的variables都是在程序的某个地方定义的,所以这不应该成为问题。 当我尝试运行脚本时,我不断收到错误: http.js:783 throw new TypeError('first argument must be a string or Buffer'); TypeError: first argument must be a string or Buffer 那么熟悉node.js或javascript语法的人可以让我知道问题是什么? upload = function(req, res) { var fileInfos = [obj, obj]; //defined as an array of objects var counter = 0; counter -= 1; if (!counter) { res.end({files: fileInfos}); //files is […]

SyntaxError在我的node.js Express代码中

所以我试图按照这个教程video: http://nodetuts.com/tutorials/13-authentication-in-express-sessions-and-route-middleware.html#video 正因为如此,我已经得到了这个代码在我的routes/index.js文件的顶部: var todo = require('../todo'); //line 1 //line 2 //new session //line 3 exports.newSession = function (req, res) { //line 4 res.render('sessions/new', { //**line 5** locals: { redir: req.query.redir } }); }; 但是,当我运行我的应用程序,并触发routes.newSession处理程序,我得到这个错误: 500 SyntaxError: Unexpected identifier at Object.Function (unknown source) at Object.compile (/home/admin73464/todo/node_modules/jade/lib/jade.js:161:8) at Function.compile (/home/admin73464/todo/node_modules/express/lib/view.js:65:33) at ServerResponse._render (/home/admin73464/todo/node_modules/express/lib/view.js:414:18) at ServerResponse.render (/home/admin73464/todo/node_modules/express/lib/view.js:315:17) […]

在hashbang行eclipse javascript语法错误

当我将一些现有的node.js代码导入到Eclipse工作区时,它会抱怨 令牌上的语法错误“无效字符”,请删除此令牌 在#! /usr/bin/env/node #! /usr/bin/env/node hashbang行。 我怎么能告诉日食忽略这个错误?

语法错误@@

我目前正在尝试为ARMv7l编译nodejs,所以我跟着这个tuto: http ://fastr.github.io/articles/cross-compiling-node.js-for-arm.html 但是当我做./configure –without-ssl我有这个错误: /src/node-v0.1.104/deps/libev/wscript: error: Traceback (most recent call last): File "/src/node-v0.1.104/tools/wafadmin/Utils.py", line 274, in load_module exec(compile(code, file_path, 'exec'), module.__dict__) File "/src/node-v0.1.104/deps/libev/wscript", line 3 @@ -41,6 +41,7 @@ def configure(conf): ^ SyntaxError: invalid syntax

:如何设置返回的数据顺序

我有问题设置返回的数据顺序的限制和偏移量的findAll查询,我使用文档中find的示例代码: order: 'group DESC'但它会抛出一个错误说: Error: SQLITE_ERROR: near "group": syntax error 这是完整的function。 A_Model.findAll({ offset:req.query.page * req.query.rows – req.query.rows, limit :req.query.rows // TODO: Of course, I put the trailing comma here 😉 // TODO: order: 'group DESC' }) .success(function (docs) { response_from_server.records = count; response_from_server.page = req.query.page; response_from_server.total = Math.ceil(count / req.query.rows); response_from_server.rows = []; for (item […]

Nodemailer错误无法修复

我有一个非常简单的应用程序,刚开始用nodemailer弄脏我的手。 当我运行应用程序,我得到模块本身的错误。 app.js: const nodemailer = require('nodemailer'); const transporter = nodemailer.createTransport('smtps://me%40gmail.com:supersecretpw@smtp.gmail.com'); var mailOptions = { from: '"Me" <me@gmail.com>', // sender address to: 'him@him.com, her@her.com', // list of receivers subject: 'Hello dude', // Subject line text: 'Test email with text', // plaintext body html: "Testing 1..2..7" // html body }; // send mail with defined transport […]