process.version
新增于: v0.1.3
process.version 属性包含 Node.js 版本字符串。
\The process.version property contains the Node.js version string.
import { version } from 'node:process'; console.log(`Version: ${version}`); // Version: v14.8.0const { version } = require('node:process'); console.log(`Version: ${version}`); // Version: v14.8.0
要获取不带前缀 v 的版本字符串,请使用 process.versions.node。
\To get the version string without the prepended v, use
process.versions.node.