Closed strogonoff closed 3 years ago
Can you try to execute that on your environment?
console.Console({ stdout: process.stdout, stderr: process.stderr });
As described here: https://nodejs.org/docs/latest-v12.x/api/console.html#console_new_console_stdout_stderr_ignoreerrors
I suspect that console
is not available in Electron or something similar. I'm not expert about Electron. Which node version are you using? Electron uses a built-in version?
thanks
I believe latest Electron bundles Node 12.16.3. Thanks, I’ll look into it
The problem is the assumption that the current console object is the NodeJS object. For example if you use a log framework as electron-log the Console costructor don't exists.
A simple patch ( work in my case ) is:
@@ -435,7 +437,12 @@ export class PluginVm {
sandbox.process = Object.create(srcGlobal.process || null);
}
if (!sandbox.console) {
- sandbox.console = new console.Console({ stdout: process.stdout, stderr: process.stderr });
+ if(console.Console){
+ sandbox.console = new console.Console({ stdout: process.stdout, stderr: process.stderr });
+ } else {
+ const { Console } = require('console');
+ sandbox.console = new Console({ stdout: process.stdout, stderr: process.stderr });
+ }
}
// override the global obj to "unlink" it from the original global obj
Thanks @dianlight ! Do you want to create a PR?
It would be great to have some sort of unit test or example to reproduce this problem...
@davideicardi now I don’t have much time. I will see what I can do.
I triple-checked and everything else left alone 0.15.1 results in an error while 0.15.0 works, so this must be a regression.
The error happens when plugin manager is used in browser context (Electron renderer) and is thrown by this specific line:
https://github.com/davideicardi/live-plugin-manager/blob/881a95c8a0b5d1895d0d7c32855f2914e9419e6b/src/PluginVm.ts#L438
I’ll try to copy the exact error later, it’s about
console.Console
either missing or not being a constructor.For now downgraded to 0.15.0.
New user here, nice work!