gpt4 book ai didi

javascript - 在 NodeJS 上添加异步函数时出错

转载 作者:行者123 更新时间:2023-11-29 20:30:50 24 4
gpt4 key购买 nike

我正在尝试在 node.js v6.11 上添加 async 方法,但是我收到了 Unexpected identifier 错误。

let fs = require('fs');
let Config = require('../somefolders/config.js');

module.exports = class SomeClassName {
constructor(id = null) {

}

//Some other methods

static async test1234(param) {

}

//Some other Static methods
}

这是我们得到的错误:

Error

最佳答案

屏幕截图中的错误告诉我们您使用的是不支持 async/await 的旧版本 Node.js。 Node.js 多年来一直使用 async/await,但如果我回到 v7,我可以准确地复制您屏幕截图中的错误。

如果您更新到最新版本的 Node.js(或者甚至是一个模糊的最新版本),该代码就没问题。

关于javascript - 在 NodeJS 上添加异步函数时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58390688/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com