Debian – Does the Linux version of Node.js come bundled with libv8

debiannode.jspackage-management

I'm a bit confused as to how Node.js gets access to libv8.

I downloaded the 64-bit "Linux Binaries (.tar.xz)" for version 6.5.0 of Node.js and extracted them to /opt on my Debian Linux machine. When I run node -e "console.log(process.versions.v8)", I get 5.1.281.81, which is the recent version of V8 I would expect to see running with Node 6.5.0. However, when I look at Synaptic Package Manager in Debian, its nodejs package has a dependency on the libv8-3.14.5 package; a much older version of V8.

So which is it – does Node use the installed libv8 (the package manager indicates that 3.14.5 is installed on my machine) or does V8 come bundled with Node.js? Is it compiled into the node binary? If so, why does the package manager have the libv8 dependency?

Best Answer

When you download Node.js from the download site, the binary you get is statically linked against libv8 5.1.281.81. There are a number of ways to verify this:

  • look for libv8 in the binary:

    strings bin/node | less -plibv8
    

    (this will lead you to the "5.1.281.81" string in the binary)

  • list the symbols in the binary and unmangle them:

    nm bin/node | c++filt | less -pv8::
    

    (the v8:: symbols come from libv8).

The archive you downloaded doesn't use Debian's packaging system, so the package manager's dependencies don't come into consideration. If you didn't install the libv8-3.14.5 package explicitly, presumably some other package installed on your system depends on it. If nothing actually needs it, you can remove libv8-3.14.5 and you'll see that the node binary in /opt works fine without it.

In any case, even with a packaged version of Node.js you wouldn't necessarily see a dependency on libv8, because Node.js includes the source of the V8 engine; it's not a separate library (at least not for Node.js).

(To run the above commands, you'll need to install the binutils package for nm and c++filt.)

Related Question