Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to develop Google Chrome extensions using node.js?

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?

like image 950
Anderson Green Avatar asked Sep 25 '12 03:09

Anderson Green


People also ask

Are Chrome extensions written in js?

On a basic level, an extension is just a collection of HTML, CSS and JavaScript snippets that lets us execute some extra functionalities through the JavaScript APIs that the Chrome browser exposes. In layman's terms, an extension is mostly a webpage hosted inside Chrome with access to some specific APIs.

Can you use NPM with chrome extension?

Now if you enter npm run build into your terminal it will build a chrome extension. I also added an npm run dev functionality that automatically rebuilds the app when you make any changes to your app. This makes debugging easier. You will have to install Extension Reloader to quickly reload any new changes after build.

Can Nodejs used in browser?

js is a server-side JavaScript run-time environment. It's open-source, including Google's V8 engine, libuv for cross-platform compatibility, and a core library. Notably, Node. js does not expose a global "window" object, since it does not run within a browser.


2 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.

like image 152
wesleycoder Avatar answered Sep 18 '22 02:09

wesleycoder


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.

like image 27
saeed Avatar answered Sep 21 '22 02:09

saeed