Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run Node.js modules on browser using Chrome extension

For my college project, I'm creating a Chrome extension to perform certain checks and validations for each URL the user visits on his browser. My aim is to alert the user when a suspicious site is detected using Chrome extension. So for this purpose, I need to use certain NPM modules such as whois-json, get-ssl-certificate and so on. So, since Node.js cannot run on the browser directly, I tried using Browserify module to convert this Node.js code such as require and module execution into plain Javascript bundle file. So, when I try to run this Javascript bundle using the Chrome extension, I get an error as:

"net.connect" is not a function

Is there any possible way to fix this error? Or can I use another solution as an alternative to Browserify to run my Node.js modules on the Chrome Extension.

like image 610
Vinit Neogi Avatar asked Oct 17 '25 17:10

Vinit Neogi


1 Answers

No, you won't be able to use Node.js modules that use server-specific code in a Chrome extension. You have a few options here though.

  1. You could look for alternative modules that use browser APIs and use those instead.

  2. You could look for public REST APIs that achieve what your Node.js modules are doing.

  3. You could create your own REST API with the existing Node.js code you have, and then interface with that from your client-side Chrome extension.

like image 169
Tim Novis Avatar answered Oct 19 '25 08:10

Tim Novis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!