V8 如何与 NodeJs 一起安装?我目前的 V8 引擎是什么版本?
12 回答
一站式解决方案:
node -p process.versions.v8
替代解决方案:
node -e "console.log(process.versions.v8)"
简单的方法:
在命令行中输入:node -p process.versions.v8
艰辛的道路:
键入
node --version
以获取 Node.js 版本。转到Node.js 变更日志。
查找并打开适当的 Node.js 版本更改日志。
查找包含
V8 to
.
运行npm version
(不知道什么时候可用)
> npm version
{ http_parser: '1.0',
node: '0.10.35',
v8: '3.14.5.9',
ares: '1.9.0-DEV',
uv: '0.10.30',
zlib: '1.2.8',
modules: '11',
openssl: '1.0.1j',
npm: '1.4.28',
xsjs: '0.1.5' }
要检查您的版本,请检查process.versions
REPL 中的值。
node -e "console.log(process.versions.v8);"
此外,如果需要,您可以使用其他版本的 V8 编译 node。显然,根据您选择的版本,结果可能会有很大差异。
cd node-v0.x.x
rm -rf deps/v8
git clone http://github.com/v8/v8.git deps/v8
./configure
make
make install
您只需键入:
node -p process.versions.v8
只是为了好玩,如果您的终端中有 curl 可用,以下应该为您提供 v8 的版本:
V=`cat /usr/include/node/node_version.h | grep -E '^\#define NODE_(MAJOR|MINOR|PATCH)_VERSION' | sed -e 's/^[^0-9]*//'`; V=`echo $V | sed -e 's/ /\./g'`; URL=https://github.com/joyent/node/raw/v$V/ChangeLog; curl --silent $URL | grep 'Upgrade v8' | head -1 | sed -e 's/^.* //'; unset V; unset URL
例如,在我的带有 node.js 0.4.7 的盒子中,我得到:
3.1.8.10
:)
使用 node.js 找到已安装的 v8 版本。
$ node
> process.versions.v8
'5.1.281.83'
>
其中process对象是一个全局对象,它提供有关当前 Node.js 进程的信息并对其进行控制。
如果您只是在 node repl 中键入 process,您会看到有关 node 的信息(即 node 版本、v8 版本、平台、env 变量信息等)
如果您使用的是 Node.js 版本 7.7.3 或类似版本,则命令为
$ node -p "process.versions"
但是上面的那些也很好用。
node -pe 'this.process.versions' # all versions
node -pe 'this.process.versions.v8' # v8 version
其他答案非常适合检查您当前的版本。这里还有一个包含所有 Node.js 版本的表格:https ://nodejs.org/en/download/releases/ 。摘录例如:
Version Date V8 npm NODE_MODULE_VERSION
Node.js 11.0.0 2018-10-23 7.0.276.28 6.4.1 67
Node.js 10.13.0 2018-10-30 6.8.275.32 6.4.1 64
Node.js 10.12.0 2018-10-10 6.8.275.32 6.4.1 64
您还可以使用 docker 检查任何 nodejs v8 版本,例如 node 10.7.0
:
docker run --rm -it node:10.7.0 bash -c "node -p process.versions"
v8 与 Node.js 捆绑在一起。您可以通过查看存储库中的 v8ChangeLog
来查看任何版本的 Node.js 正在使用的 v8 版本以及它何时投入生产。node
这是当前的主人(如果从源代码构建):
https ://github.com/nodejs/node/commits/master/deps/v8/ChangeLog
要查看特定版本的 Node.js,请将分支切换到该版本并检查ChangeLog
s 文件历史记录。