常量令牌 = this.client.token ??this.client.accessToken;SyntaxError:意外的令牌'?repl.it 最新节点 [英] const token = this.client.token ?? this.client.accessToken; SyntaxError: Unexpected token '?' repl.it with latest node

查看:17
本文介绍了常量令牌 = this.client.token ??this.client.accessToken;SyntaxError:意外的令牌'?repl.it 最新节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了最新的节点版本v16,当我使用运行按钮或控制台启动机器人时,它给我带来了这个错误:

I have the latest node version installed v16 and when i start the bot with the run button or the console it brings me this error:

const token = this.client.token ?? this.client.accessToken;
                                     ^

SyntaxError: Unexpected token '?' 

但是当使用 shell 并输入 node index.js 时,它可以正常工作.所以我不明白什么是 repl.当一切都是最新的时,它会如此沮丧吗?

But when using shell and typing in node index.js it works fine. So I don't understand what's repl.it so upset about when all is up-to-date?

推荐答案

在shell中运行npm install node@16

创建一个名为 .replit

在 .replit 文件中,添加 run = "npx node index.js".如果您的主文件名称不同,请将 index.js 更改为您的主文件名称.

Inside the .replit file, add run = "npx node index.js". If your main file has a different name change index.js to your main file's name.

现在当你点击运行时,replit 使用 node.js v16 而不是 v12

Now when you click run, replit uses node.js v16 instead of v12

这篇关于常量令牌 = this.client.token ??this.client.accessToken;SyntaxError:意外的令牌'?repl.it 最新节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆