Skip to content

SyntaxError: Unexpected token ':' #304

@minkuang1982

Description

@minkuang1982

D:\AI\DingDongBot>node dingdongbot.js
file:///D:/AI/DingDongBot/dingdongbot.js:20
function onScan (qrcode: string, status: ScanStatus) {
^

SyntaxError: Unexpected token ':'
at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:167:18)
at callTranslator (node:internal/modules/esm/loader:285:14)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:30)
at async link (node:internal/modules/esm/module_job:76:21)

Node.js v20.11.0

D:\AI\DingDongBot>node -v
v20.11.0

D:\AI\DingDongBot>npm -v
10.2.4

this is the code same as the example

function onScan (qrcode: string, status: ScanStatus) {
if (status === ScanStatus.Waiting || status === ScanStatus.Timeout) {
const qrcodeImageUrl = [
'https://wechaty.js.org/qrcode/',
encodeURIComponent(qrcode),
].join('')
log.info('StarterBot', 'onScan: %s(%s) - %s', ScanStatus[status], status, qrcodeImageUrl)

qrcodeTerminal.generate(qrcode, { small: true })  // show qrcode on console

} else {
log.info('StarterBot', 'onScan: %s(%s)', ScanStatus[status], status)
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions