作者:云妹12241999 | 来源:互联网 | 2023-02-02 08:39
ImintendingtousewebworkerinsidemyNode.jsapplicationforsomeconcurrenttasks.Howeversin
I'm intending to use web worker inside my Node.js application for some concurrent tasks. However since the 'webworker-threads'
module follows the implementation of HTML5 web worker, requiring Nodejs modules like require("fs")
inside web worker does not work. importScripts()
can load js files but I would like a functionality inside the web worker so that I can require
npm-installed modules. Is there a workaround for that?
我打算在我的Node.js应用程序中使用web worker来完成一些并发任务。但是,由于'webworker-threads'模块遵循HTML5 web worker的实现,因此在web worker中需要Nodejs模块(如require(“fs”))不起作用。 importScripts()可以加载js文件,但我想在web worker中使用一个功能,这样我就可以安装npm安装的模块。有没有解决方法呢?
1 个解决方案