40

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

4

5 回答 5

27

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

console.log(process.versions);

输出

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

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

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

于 2012-07-29T08:11:04.480 回答
7

运行此脚本:

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 :(")
}
于 2019-11-20T20:36:52.190 回答
6

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

node -p process.versions.v8
于 2016-11-11T20:55:39.320 回答
5

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

于 2020-02-20T20:57:40.997 回答
3

不是想在这里发布 necropost —— 然而,这似乎是实现这一点的方法……然而,这有点令人费解。

我所做的是 - 按照此处概述的方法,然后添加一些我自己的...

节点-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' }

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

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

对于 Linux 使用...

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

如果你省略了 grep/find 的管道,你会得到一长串所有可用的 v8 选项。

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

节点-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' }

节点--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))
于 2018-12-11T04:24:16.043 回答