Closed StNekroman closed 2 years ago
When I code inside vm2 (which is inside thread worker) I receive "Module not found error" Module is present in host project inside /node_modules/ as "npm link" I have a workaround:
builtin: ["fs", "path", "util", "discord-text-games-api", "discord-text-games-api/dto", "discord-text-games-api/events"], resolve: (moduleName: string, parentDirname: string) : string | undefined => { if (moduleName === "discord-text-games-api" || moduleName === "discord-text-games-api/events") { return path.join(process.cwd(), "node_modules", "discord-text-games-api"); } }
With workaround I manually require (from host scope) that module and pass it down. Without workaround - it cannot locate module. Any thoughts?
Ah, after debuging I found, that VM2's root property restricts access to hosts's node_modules.
When I code inside vm2 (which is inside thread worker) I receive "Module not found error" Module is present in host project inside /node_modules/ as "npm link" I have a workaround:
With workaround I manually require (from host scope) that module and pass it down. Without workaround - it cannot locate module. Any thoughts?