Search code examples
javascriptnode.jsruntimev8libuv

In Node.js If v8 Runs Your JavaScript, What Runs The Node.js Api?


I'm trying to understand the internal structure of Node.js. To my understanding V8 runs the JavaScript(EcmaScript) which makes sense. Since all the Node.js Api is not JavaScript but looks like JavaScript, My question is, what runs the Node.js Api. For example what runs

http.createServer();

Or

fs.readFile();

Solution

  • All of Node.js API is JavaScript.

    Only the I/O operations are delegated to the libuv library which is written entirely in C. Stuff like fs.readFile is just wrappers around libuv functions, the so called POSIX API.