如何知道我的 NODEJS 中的哪个 javascript 版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11707698/
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-10-26 14:05:12  来源:igfitidea点击:

how to know which javascript version in my NODEJS?

javascriptnode.jsversionv8

提问by Dexter

I want to know which javascript version is my NodeJS is supporting ?

我想知道我的 NodeJS 支持哪个 javascript 版本?

回答by Anirudh Ramanathan

Use process.versions. From that page in the documentation:

使用process.versions。从文档中的那个页面:

console.log(process.versions);

outputs

输出

{ node: '0.4.12',
  v8: '3.1.8.26',
  ares: '1.7.4',
  ev: '4.4',
  openssl: '1.0.0e-fips' }

EDIT: V8 uses the ECMAScript as specified in ECMA-262, 5th edition.

编辑:V8 使用ECMA-262, 5th edition 中指定ECMAScript

Reference: http://code.google.com/p/v8/

参考:http: //code.google.com/p/v8/

回答by martinho

Run this script:

运行这个脚本:

try {
  var k = new Map();
  console.log("ES6 supported!!")
} catch(err) {
  console.log("ES6 not supported :(")
}

try {
  var k = new HashMap();
  console.log("ES100 supported!!")
} catch(err) {
  console.log("ES100 not supported :(")
}

回答by K-Gun

According to its documentation, this command could be used;

根据其文档,可以使用此命令;

node -p process.versions.v8

回答by jinzai

Not trying to necropost, here -- however, this seems to be the way to accomplish this...it is a bit convoluted, however.

不是试图在此处进行尸检——然而,这似乎是实现这一目标的方式......然而,这有点令人费解。

What I did was -- follow the method outlined here and then added some of my own...

我所做的是——按照这里概述的方法,然后添加一些我自己的......

node -p process.versions

node -p process.versions

{ http_parser: '2.8.0',
  node: '11.2.0',
  **v8: '7.0.276.38-node.11'**,
  uv: '1.23.2',
  zlib: '1.2.11',
  ares: '1.15.0',
  modules: '67',
  nghttp2: '1.34.0',
  napi: '3',
  openssl: '1.1.0i',
  icu: '63.1',
  unicode: '11.0',
  cldr: '34.0',
  tz: '2018e' }

Then, it depends on your platform -- I have node running on Windows 10, so...

然后,这取决于您的平台——我的节点运行在 Windows 10 上,所以......

node --v8-options | find "in progress"

节点 --v8-options | 找到“进行中”

For Linux use...

对于 Linux 使用...

node --v8-options | grep "in progress"

节点 --v8-options | grep“进行中”

  --harmony-do-expressions (enable "harmony do-expressions" (in progress))
  --harmony-class-fields (enable "harmony fields in class literals" (in progress))
  --harmony-static-fields (enable "harmony static fields in class literals" (in progress))
  --harmony-await-optimization (enable "harmony await taking 1 tick" (in progress))
  --harmony-locale (enable "Intl.Locale" (in progress))
  --harmony-intl-list-format (enable "Intl.ListFormat" (in progress))
  --harmony-intl-relative-time-format (enable "Intl.RelativeTimeFormat" (in progress))

V8 implements ECMAScript as defined in ECMA-262-- I am unaware of any way to relate that to any other 'version', however -- it will tell you what features are still in development.

V8 实现了 ECMA-262 中定义的 ECMAScript——我不知道有什么方法可以将它与任何其他“版本”相关联,但是——它会告诉你哪些功能仍在开发中。

If you omit the pipe to grep/find, you get a long list of all v8 options available.

如果省略 grep/find 的管道,您将获得一长串所有可用的 v8 选项。

Finally, I am not actually developing the Node application for use on my Windows 10 machine -- I am developing the Node application for a Raspberry Pi and using Visual Studio Code to ssh, so -- at my terminal prompt, I ssh into the RPi and use the Linux version above...

最后,我实际上并没有开发在我的 Windows 10 机器上使用的 Node 应用程序——我正在为 Raspberry Pi 开发 Node 应用程序并使用 Visual Studio Code 进行 ssh,因此——在我的终端提示符下,我 ssh 进入 RPi并使用上面的Linux版本...

node -p process.versions

node -p process.versions

{ http_parser: '2.8.0',
  node: '8.11.3',
  v8: '6.2.414.54',
  uv: '1.19.1',
  zlib: '1.2.11',
  ares: '1.10.1-DEV',
  modules: '57',
  nghttp2: '1.32.0',
  napi: '3',
  openssl: '1.0.2o',
  icu: '60.1',
  unicode: '10.0',
  cldr: '32.0',
  tz: '2017c' }

node --v8-options | grep "in progress"

节点 --v8-options | grep“进行中”

--harmony_array_prototype_values (enable "harmony Array.prototype.values" (in progress))
--harmony_function_sent (enable "harmony function.sent" (in progress))
--harmony_do_expressions (enable "harmony do-expressions" (in progress))
--harmony_class_fields (enable "harmony public fields in class literals" (in progress))
--harmony_promise_finally (enable "harmony Promise.prototype.finally" (in progress))
--harmony_number_format_to_parts (enable "Intl.NumberFormat.prototype.formatToParts" (in progress))
--harmony_plural_rules (enable "Intl.PluralRules" (in progress))

回答by beencodingawhile

The best and most detailed version intel is at https://node.green. It shows a matrix of NodeJS version by JavaScript version. The JavaScript items include the standard name and each js feature. The node version includes the V8 version (hover over the node column header).

最好和最详细的英特尔版本位于https://node.green。它显示了 JavaScript 版本的 NodeJS 版本矩阵。JavaScript 项包括标准名称和每个 js 功能。节点版本包括 V8 版本(将鼠标悬停在节点列标题上)。