[英]SyntaxError: Unexpected token > in Coffeescript
I just started learning Coffeescript and have syntax error that I can't figure out. 我刚刚开始学习Coffeescript,但遇到语法错误,无法弄清。 I have written the following code: 我写了以下代码:
exports.list = (req, res) ->
User.find({}).select('username').exec (err, results) ->
if err
res.send(err)
else
console.log(results)
viewData =
title: 'Users'
users: results
res.render 'users', viewData
return
return
When executed it throws SyntaxError: Unexpected token > on line 1
, but as far as I know this should be the right syntax for Coffeescript? 执行时,它SyntaxError: Unexpected token > on line 1
引发SyntaxError: Unexpected token > on line 1
,但据我所知,这应该是Coffeescript的正确语法?
The code is valid CoffeeScript. 该代码是有效的CoffeeScript。
It appears that whatever is executing this code is expecting JavaScript, not CoffeeScript. 似乎执行此代码的任何人都期望使用JavaScript,而不是CoffeeScript。 By pasting your code into a JavaScript console I got the exact same error. 通过将代码粘贴到JavaScript控制台中,我得到了完全相同的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.