What is the relationship between Node.js and V8?

What is the relationship between Node.js and V8?

V8 is the Javascript engine inside of node.js that parses and runs your Javascript. The same V8 engine is used inside of Chrome to run javascript in the Chrome browser. Google open-sourced the V8 engine and the builders of node.js used it to run Javascript in node.js.

Can Node.js work without V8?

No. The current node.js binary cannot work without V8. It would have no Javascript engine and thus no ability to run code which would obviously render it non-functional. Node.js was not designed to run with any other Javascript engine and, in fact, all the native code bindings that come with node.js (such as the fs module or the net module) all rely on the specific V8 interface between C++ and Javascript.

There is an effort by Microsoft to allow the Chakra Javascript engine (that's the engine in Edge) to be used with node.js. They build a V8 shim on top of Chakra so that the node.js binary code that expects to be talking to V8 can continue to do what it was doing, but actually end up talking to the Chakra engine underneath. From what I've read this is particularly targeted at Microsoft platforms that already have the Chakra engine and do not have the V8 engine running on them, though presumably you could use it on Windows too.


Node.js can actually function to some extent without V8, through use of the node-chakracore project. There is ongoing work to reduce the tight coupling between V8 and Node, so that different JavaScript engines can be used in-place.


Many beginners think that nodejs is a programming language but it is not. Before getting into the relation between v8 and nodejs lets see what V8 actually is.

V8

V8 is a javascript engine. A javascript engine is used to interpret javascript code to machine code. There are different javascript engines ex: V8 for chrome, Chakra for IE, Spider monkey for Netscape etc.

nodejs and V8

V8 is a browser engine whereas nodejs is built on top of V8 which is a runtime environment that gives javascript the power to run at the server-side.

Can Node.js work without V8?

Yes, but I have never used nodejs with other javascript engines.

Tags:

V8

Node.Js