I'd like to start developing Google Chrome extension using node.js (since I've already written a "text-to-song" script in node.js, and I'd like to turn it into a Chrome extension.) What would be the most straightforward way of approaching this problem?
-
3chrome extension is client-side whereas node.js is server-side – vinayr Sep 25 '12 at 04:04
-
4@vinayr Yes, I'm asking whether it's possible to install a local node.js server as a Chrome extension (perhaps using NPAPI). – Anderson Green Sep 25 '12 at 04:14
-
I found a related project (that allows Node modules to be used directly accessed from DOM, using WebKit): http://stackoverflow.com/questions/8794140/is-it-possible-to-create-desktop-applications-with-node-js – Anderson Green Nov 15 '12 at 06:35
-
@vinayr Wouldn't it be possible to install a local node.js server with a Chrome extension using NPAPI?http://stackoverflow.com/questions/3695476/how-do-i-perform-a-shell-execute-in-a-chrome-extension?lq=1 – Anderson Green Jan 05 '13 at 18:18
-
1check this out http://iceddev.github.com/blog/2012/11/05/node-js-in-chrome/ – vinayr Jan 06 '13 at 06:00
-
Also, I just found this: https://www.npmjs.com/package/generator-chrome-extension – wadie Jun 03 '18 at 14:18
3 Answers
Actually it is. Look at this Developers Live-cast. This is something I've been looking for as well, and this would help you.
This brings your node applications bundled to your browser. Here is the repo!
EDIT:
I've noticed that this old answer of mine keeps getting upvotes now and then (thank you all).
But nowadays I'm more an advocate of using web apps instead of bundling your application into many platforms like the chrome store or whatever. You can check the google's post here and here indicating some directions.
In practice I advise for you to start building a progressive web app (PWA) with offline capabilities using service worker and progressive stuff.
There are plenty of resources around the web nowadays and you can offer a much richer application that may achieve a much broader audience if you do it the right way.
Thanks again, and good coding.

- 1,139
- 1
- 12
- 21
-
Is there any relation between these two projects? One of them is intended to allow CommonJS modules to be used in the browser, while the other is an attempt to allow node.js interoperability with Chrome Packaged Apps. – Anderson Green Jan 05 '13 at 18:16
-
1I found another project that uses node-browserify to create Chrome extensions, called node-chromify: http://iceddev.github.com/blog/2012/11/05/node-js-in-chrome/ – Anderson Green Jan 26 '13 at 00:18
-
2but this doesn't bring all capabilities of nodejs into extension. – Muhammad Umer Sep 08 '13 at 21:02
-
1It is possible to 'browserify' a Node.js script and run it in a Chrome extension. Just use examples from the repo mentioned above (https://github.com/iceddev/node-chromify). It is enough to go to Chrome extensions and select for instance the 'http' example. After that you have a running Node.js server in a Chrome browser. Unfortunately I cannot do the same with a websocket server: http://stackoverflow.com/questions/20538184/how-to-browserify-a-node-js-websocket-server – gvlax Dec 12 '13 at 21:08
Simple answer is NO, unless you can find a way to install node.js with an extension using NPAPI.
Nodejs and a Google Chrome Extension do have a couple things in common i.e they both understand javascript and they both use the v8 javascript engine.
Google Chrome Extension
"Google Chrome Extensions are small software programs that can modify and enhance the functionality of the Chrome browser".
To develop a Google Chrome Extension you should write some javascript and or html/css. Then you can run the extension in your browser.
If you wish for others to download your extension you will have to provide config.json file that describes you extension sets permissions etc.
Nodejs
"Node.js is a platform built on Google Chrome's JavaScript runtime for easily building fast, scalable network applications".
To develop applications in nodejs you write some javascript and or html/css for web applications.
If wish for others to use you application you start you nodejs server and listen for incoming requests.
Summary
Despite some of the similarities a Google Chrome Extension and Nodejs have nothing to with each other. You cannot use them together in some special way outside of the normal client/server communication.
-
Are you sure that it isn't possible to install a local web server (or other plugin) using a Chrome Extension? This topic gives some details on using NPAPI to install local a local web server using a browser extension: http://stackoverflow.com/questions/5053244/is-it-possible-to-embed-a-http-server-in-a-google-chrome-extension – Anderson Green Sep 25 '12 at 16:04
-
Basically, I'm trying to create a Chrome extension that can install a web server on the user's computer. (Perhaps this could be done by invoking a shell command from the Chrome extension, for example, on Ubuntu: sudo apt-get install name-of-package-to-install). – Anderson Green Sep 25 '12 at 16:07
-
No. Google Chrome will not allow this. This will open-up a huge security issue. The only way is to get the user to install an actual program outside Chrome. Chrome extensions are sandboxed and cannot do things like "sudo apt-get install name-of-package-to-install". – saeed Sep 25 '12 at 16:44
-
1It appears that it's possible to do this using NPAPI: http://stackoverflow.com/questions/3695476/how-do-i-perform-a-shell-execute-in-a-chrome-extension – Anderson Green Sep 25 '12 at 17:17
-
I stand corrected. I guess Google are getting around the security issues my requiring manual review. – saeed Sep 25 '12 at 17:39
-
Also, there's a really interesting project called node-webkit that integrates the Chromium browser with node.js, allowing node.js to be accessed directly from the DOM (like regular client-side Javascript). It's based on a modified version of the Chromium browser - I wonder if it would be possible to develop node.js-based extensions using node-webkit? – Anderson Green Nov 15 '12 at 20:25
-
More information about node-webkit can be found here: https://github.com/rogerwang/node-webkit – Anderson Green Nov 15 '12 at 20:27
-
Hey, I used the node-chromify project in my chrome app. But what if I want to use external modules like nodejitsu's node-http-server? How do I install it? – user1151659 Apr 02 '14 at 15:39
You can use a WebPack (GitHub) or Browserify (see handbook) to build web-browser extension based on the node.js code.
With Browserify, to convert your code, you can simply run:
browserify node-code.js -o node-code-out.js
Read more:

- 155,785
- 88
- 678
- 743