如何检查我的 NodeJS 安装了哪个版本的 v8?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5356113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 13:57:46  来源:igfitidea点击:

How to check which version of v8 is installed with my NodeJS?

node.jsv8

提问by Lalith

How is V8 installed along with NodeJs? What version is my current V8 engine?

V8 是如何与 NodeJs 一起安装的?我当前的 V8 引擎是什么版本?

采纳答案by alienhard

Easy way:
Type in command line: node -p process.versions.v8

简单的方法:
在命令行中输入:node -p process.versions.v8

Hard worker way:

勤劳的方式:

  1. Type node --versionto get the Node.js version.

  2. Go to the Node.js Changelogs.

  3. Find and open appropriate Node.js version change log.

  4. Look for notes containing V8 to.

  1. 键入node --version以获取 Node.js 版本。

  2. 转到Node.js 更新日志

  3. 查找并打开相应的 Node.js 版本更改日志。

  4. 查找包含V8 to.

回答by

One-line solution:
node -p process.versions.v8

一线解决方案:
node -p process.versions.v8

Alternative solution:
node -e "console.log(process.versions.v8)"

替代解决方案:
node -e "console.log(process.versions.v8)"

回答by Peter Dotchev

Just run npm version(don't know since when this is available)

只需运行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' }

回答by Ben Taber

To check your version, check the value in process.versionsin the REPL.

要检查您的版本,请检查process.versionsREPL 中的值。

node -e "console.log(process.versions.v8);"

Additionally, you can compile node with other versions of V8 if you desire. Obviously results may vary widely here depending on what versions you choose.

此外,如果您愿意,您可以使用其他版本的 V8 编译节点。显然,根据您选择的版本,结果可能会有很大差异。

cd node-v0.x.x
rm -rf deps/v8
git clone http://github.com/v8/v8.git deps/v8

./configure
make
make install

回答by Gaui

You can just type:

您只需键入:

node -p process.versions.v8

node -p process.versions.v8

回答by Siyaram Malav

find the installed v8 version with node.

使用 node.js 查找已安装的 v8 版本。

$ node
> process.versions.v8
'5.1.281.83'
>

where The processobject is a global that provides information about, and control over, the current Node.js process.

其中process对象是一个全局对象,它提供有关当前 Node.js 进程的信息并对其进行控制。

if you just type process in node repl, you see information about node(i.e. node version,v8 version,platform,env variables info etc.)

如果您只是在 node repl 中键入 process,您会看到有关 node 的信息(即 node 版本、v8 版本、平台、env 变量信息等)

回答by rust

If you're on Node.js version 7.7.3 or similar the command is

如果您使用的是 Node.js 版本 7.7.3 或类似版本,则命令是

$ node -p "process.versions"

But those above work fine too.

但上面的那些也很好用。

回答by Mariano Iglesias

Just for fun, if you have curl available in your terminal, the following should give you v8's version:

只是为了好玩,如果你的终端中有 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

For example, in my box with node.js 0.4.7 I get:

例如,在我的 node.js 0.4.7 框中,我得到:

3.1.8.10

:)

:)

回答by Vadim

node -pe 'this.process.versions'     # all versions
node -pe 'this.process.versions.v8'  # v8 version

回答by ZachB

The other answers are great for checking your current version. There's also a table with all Node.js versions here: https://nodejs.org/en/download/releases/. Excerpt for example:

其他答案非常适合检查您当前的版本。这里还有一个包含所有 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