Warning about electron's removal of Node.js vm module
See original GitHub issueHi, I am using bytenode to encrypt my electron application source code and it works very well, here is the version I am currently using.
"bytenode": "^1.1.7"
"electron": "^12.0.0"
When I packaged the app, electron gave me a warning that
The vm module of Node.js is deprecated in the renderer process and will be removed.
This is electron’s Release Notes Persisted.
I would like to ask if electron really removed the vm module of Node.js in the renderer process, will it be affected if I continue to use bytenode?
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (1 by maintainers)
Top Results From Across the Web
Warning about electron's removal of Node.js vm module
Hi, I am using bytenode to encrypt my electron application source code and it works very well, here is the version I am...
Read more >Breaking Changes | Electron
Breaking changes will be documented here, and deprecation warnings added to JS code where possible, at least one major version before the change...
Read more >VM (executing JavaScript) | Node.js v19.3.0 Documentation
The node:vm module enables compiling and running code within V8 Virtual Machine contexts. The node:vm module is not a security mechanism. Do not...
Read more >Externals - webpack
Treat node.js built-in modules like fs , path or vm as external and load them via require() when used.
Read more >How to disable warnings when node is launched via a (global ...
The shebang I placed in the entrance script ./index.js is: #!/usr/bin/env node // my code... I have also read ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Bytenode depends on
vm
in order to work. So removing it may break bytenode.I can think of a workaround if
vm
is removed, but I need to try it first to make sure it works.Almost a year ago I was not able to remember what the workaround that I had to restore bytenode functionality if electron goes with removing
vm
module.Strangely enough, I remembered it suddenly yesterday, so I wanted to record it here before I forget it again!
Depending on how electron would remove the support for
vm
in the renderer process, we have two options:Just replace
require('vm');
withrequire('node:vm');
. This trivial solution works for now and it does not trigger the deprecation warning. ( This is because of how they are intercepting therequire
request, they only look forvm
specifically. See it here reset-search-paths.ts#L10 ).If electron decides to take a more radical approach by blocking every possible way to reach to the
vm
module (which seems unreasonable and hopefully unlikely), the other option will be creating a customvm
module. It’s a hacky solution and I have not try this workaround (fully) yet, but it should work.Hopefully not.