是否可以使用 node.js 开发 Google Chrome 扩展?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12575965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to develop Google Chrome extensions using node.js?
提问by Anderson Green
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?
我想开始使用 node.js 开发 Google Chrome 扩展程序(因为我已经在 node.js 中编写了一个“文本到歌曲”脚本,我想把它变成一个 Chrome 扩展程序。)什么将是解决这个问题的最直接的方法?
回答by wesleycoder
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 hereand hereindicating some directions.
但现在我更提倡使用网络应用程序,而不是将您的应用程序捆绑到许多平台,如 chrome 商店或其他任何平台。你可以在这里和这里查看谷歌的帖子,指出一些方向。
In practice I advise for you to start building a progressive web app (PWA) with offline capabilities using service worker and progressive stuff.
在实践中,我建议您开始使用 Service Worker 和渐进式内容构建具有离线功能的渐进式 Web 应用程序 (PWA)。
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.
再次感谢,良好的编码。
回答by saeed
Simple answer is NO, unless you can find a way to install node.js with an extension using NPAPI.
简单的答案是否定的,除非您可以找到一种使用 NPAPI 安装带有扩展的 node.js 的方法。
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.
Nodejs 和 Google Chrome 扩展程序确实有一些共同点,即它们都了解 javascript 并且都使用 v8 javascript 引擎。
Google Chrome Extension
谷歌浏览器扩展
"Google Chrome Extensions are small software programs that can modify and enhance the functionality of the Chrome browser".
“Google Chrome 扩展程序是可以修改和增强 Chrome 浏览器功能的小型软件程序”。
To develop a Google Chrome Extension you should write some javascript and or html/css. Then you can run the extension in your browser.
要开发 Google Chrome 扩展程序,您应该编写一些 javascript 和/或 html/css。然后您可以在浏览器中运行该扩展程序。
If you wish for others to download your extension you will have to provide config.json file that describes you extension sets permissions etc.
如果您希望其他人下载您的扩展程序,则必须提供 config.json 文件来描述您的扩展程序集权限等。
Nodejs
节点
"Node.js is a platform built on Google Chrome's JavaScript runtime for easily building fast, scalable network applications".
“Node.js 是一个基于 Google Chrome 的 JavaScript 运行时构建的平台,用于轻松构建快速、可扩展的网络应用程序”。
To develop applications in nodejs you write some javascript and or html/css for web applications.
要在 nodejs 中开发应用程序,您需要为 Web 应用程序编写一些 javascript 和/或 html/css。
If wish for others to use you application you start you nodejs server and listen for incoming requests.
如果希望其他人使用您的应用程序,请启动您的 nodejs 服务器并侦听传入请求。
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.
尽管有一些相似之处,但 Google Chrome 扩展程序和 Nodejs 彼此之间没有任何关系。除了正常的客户端/服务器通信之外,您不能以某种特殊方式将它们一起使用。

