Google Chrome's native client is soon to be released. http://blog.chromium.org/2011/02/native-client-getting-ready-for-takeoff.html Would this allow node.js to be run within the browser enabling distributed applications to communicate with each other without having to go through the server?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Keeping track of variable instances
Nowadays there are several solutions that allow you to run some Node modules in chrome. Have a look on these links:
node-webkit is an app runtime based on Chromium and node.js.
Node-chromify, Node.js in Chrome.
Screen cast from google about NodeJS in Chrome packaged apps.
As of today, Node.js will not run in NaCl, however it may be possible eventually. Node uses the V8 JavaScript engine to execute code. Currently there is no reliable port of the V8 engine that will run within NaCl.
From a comment by Brad Chen on Jan 28, 2014, in the thread "Has anyone tried porting Blink and V8 to Native Client?":
https://groups.google.com/d/msg/native-client-discuss/Xw5yCe3Ubwc/fgm6M092DXwJ
Considering that V8 has already been able to run under NaCl, albeit with an unreliable hack, it's reasonable to assume that Node might eventually be able to run in NaCl. I realize your question is now three years old but figured I'd provide an updated answer since running native code (even OpenGL code) in the browser is now a reality.
node.js is not pure Javascript code. There are parts of it written in C++ so this is unlikely.
There are a couple of possibilities for distributed communication. One is to use the Websockets api in the browser to communicate with other browsers. The other one is to run node.js as a separate server process on the same machine as the browser.
This second is a better choice for building a distributed application because it reduces dependence on the browser. Version 0.5.0pre of node.js now builds OK on Cygwin and it is possible to bundle up the essential components of Cygwin as a standalone binary to distribute to Windows clients. Older versions of node.js used to be distributed this way.
You can't run Node.js in a browser.
However, if you want to do P2P connection, it's possible if the browser has the latest version of Flash (Flash 10) installed. In the latest version, they introduced RTMFP which let's you do P2P connection without passing through a server. If you want to use it in Javascript, you can make a bridge or you can take a look at a project I started recently that does exactly that.