question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning about electron's removal of Node.js vm module

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
OsamaAbbascommented, Mar 6, 2021

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.

3reactions
OsamaAbbascommented, Dec 10, 2022

I can think of a workaround if vm is removed, but I need to try it first to make sure it works.

@OsamaAbbas What was your idea for the work around?

I tried to remember it but could not!

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:

  1. Just replace require('vm'); with require('node:vm');. This trivial solution works for now and it does not trigger the deprecation warning. ( This is because of how they are intercepting the require request, they only look for vm specifically. See it here reset-search-paths.ts#L10 ).

  2. 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 custom vm module. It’s a hacky solution and I have not try this workaround (fully) yet, but it should work.


bytenode will stop having support for electron?

Hopefully not.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found