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.
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.
You could look for alternative modules that use browser APIs and use those instead.
You could look for public REST APIs that achieve what your Node.js modules are doing.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With