简体   繁体   English

CoffeeScript无效语法:

[英]CoffeeScript Invalid Syntax :

I have updated my coffescript module from 1.6.3 to 1.7.1 and now my code will no longer compile. 我已经将咖啡模块从1.6.3更新到1.7.1,现在我的代码将不再编译。 What is the proper syntax for this? 正确的语法是什么? I believe it is to replace : with =. 我相信它将用=替换:。

Console Error: 控制台错误:

password: 'test',
        ^
SyntaxError: Unexpected token :

Complete snap of code section 完整的代码节

module.exports =  
 mongo_url: "mongodb://localhost:27017/testmaker_api_testing?poolSize=5"
 mock_s2:
  mac_id: "mocks2_MD"
  password: "!ensandbox1"
  domain: "talkrnd.testmaker.net"
  prod_mac_id: "mocks2_prod"
  prod_password: "!mocks21"

route_prefix: "/testmaker/v1"
user:
  userName: 'monkey',
  password: 'test',
  email: 'monkey@testmaker.com',
  fullName: 'Monkey Nackles'
  admin: true
  groups : ['Admin']

op_user:
  userName: 'booz',
  password: 'test',
  email: 'BBla@testmaker.com',
  fullName: 'Booz Bla'
  admin: false
  groups : ['op']

killable_user:
  userName: 'I will die',
  password: 'pass',
  email: 'nocener@testmaker.com',
  fullName: 'John Doe'
  admin: false
  groups : ['']

This is my config file. 这是我的配置文件。 When I complied with coffee-script 1.7.1 I was getting an error with my mongo_url line to change ":" and I changed it to "=" and the error went away but then the next error occurred at the 13th line for password. 当我遵循coffee-script 1.7.1时,mongo_url行更改为“:”时出现错误,我将其更改为“ =”,错误消失了,但是下一个错误发生在密码的第13行。 Again for "=". 再次为“ =”。 I do not believe this is an error with just the syntax. 我不相信这只是语法上的错误。

Thank you in advance 先感谢您

Try removing comma after your dictionary values, eg username: 'monkey', should be username: 'monkey' . 尝试在字典值(例如username:'monkey')应为username:'monkey'之后删除逗号。

That said, your code does compile with CoffeeScript 1.7.1. 也就是说,您的代码确实可以使用CoffeeScript 1.7.1进行编译。 Maybe there's a whitespace issue or something. 可能存在空白问题或其他问题。 Try copying the code from your question and compile it yourself. 尝试从问题中复制代码,然后自己进行编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM