Node v12 无法解析 worker_threads

问题描述

我正在使用 nodejs v12.18.3 和 npm v6.14.6 来制作一个 react 项目。我正在尝试导入 worker_threads 模块,但它无法解析模块名称(即使 vs 代码可以找到定义)。我已经确认该文件存在于 node_modules/@types/node/worker_threads.d.ts。我的包列出了 "@types/node": "^14.14.41" 作为依赖项。为什么找不到worker_threads模块?

以下是我尝试过的一些导入语句

import Worker from 'worker_threads';
import {Worker} from 'worker_threads';
import * as wt from 'worker_threads';
import Worker from '@types/node/worker_threads';
import Worker from 'node/worker_threads';
const Worker = require('worker_threads');

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)