使用 Typescript 连接 Node Redis 时出现 queueMicrotask 错误
queueMicrotask error when connecting Node Redis with Typescript
我正在尝试使用 Typescript 和 NodeRedis 连接到 Redis 服务器,但我经常收到此错误。
ReferenceError: queueMicrotask is not defined
at RedisClient._RedisClient_tick (/home/administrador/Documentos/node-api-skeleton/node_modules/redis/dist/lib/client.js:378:9)
at RedisSocket.socket_1.default.on.on.on.on (/home/administrador/Documentos/node-api-skeleton/node_modules/redis/dist/lib/client.js:301:86)
at RedisSocket.emit (events.js:198:13)
at RedisSocket.EventEmitter.emit (domain.js:448:20)
at RedisSocket._RedisSocket_connect (/home/administrador/Documentos/node-api-skeleton/node_modules/redis/dist/lib/socket.js:130:10)
at process._tickCallback (internal/process/next_tick.js:68:7)
这是代码
const redisClient = createClient();
redisClient.on('error', (err: Error) => {
console.log('Error', err.name);
});
redisClient.on('connect', () =>
console.log('Ok'));
try {
await redisClient.connect();
await redisClient.set(token, email, {
EX: 40,
NX: true,
});
await redisClient.disconnect();
} catch (err) {
console.log('Error', err);
}
我是不是漏掉了什么?
我已经解决了这个问题。不知何故,我的节点版本是 10,并且 queueMicrotasks 未在该版本中实现。我已经更新了 Node,现在可以使用了
我正在尝试使用 Typescript 和 NodeRedis 连接到 Redis 服务器,但我经常收到此错误。
ReferenceError: queueMicrotask is not defined
at RedisClient._RedisClient_tick (/home/administrador/Documentos/node-api-skeleton/node_modules/redis/dist/lib/client.js:378:9)
at RedisSocket.socket_1.default.on.on.on.on (/home/administrador/Documentos/node-api-skeleton/node_modules/redis/dist/lib/client.js:301:86)
at RedisSocket.emit (events.js:198:13)
at RedisSocket.EventEmitter.emit (domain.js:448:20)
at RedisSocket._RedisSocket_connect (/home/administrador/Documentos/node-api-skeleton/node_modules/redis/dist/lib/socket.js:130:10)
at process._tickCallback (internal/process/next_tick.js:68:7)
这是代码
const redisClient = createClient();
redisClient.on('error', (err: Error) => {
console.log('Error', err.name);
});
redisClient.on('connect', () =>
console.log('Ok'));
try {
await redisClient.connect();
await redisClient.set(token, email, {
EX: 40,
NX: true,
});
await redisClient.disconnect();
} catch (err) {
console.log('Error', err);
}
我是不是漏掉了什么?
我已经解决了这个问题。不知何故,我的节点版本是 10,并且 queueMicrotasks 未在该版本中实现。我已经更新了 Node,现在可以使用了