process.platform
process.platform
属性返回标识运行 Node.js 进程的操作系统平台的字符串。
目前可能的值是:
'aix'
'darwin'
'freebsd'
'linux'
'openbsd'
'sunos'
'win32'
console.log(`This platform is ${process.platform}`);
如果 Node.js 是在安卓操作系统上构建的,则也可能返回值 'android'
。
但是,Node.js 中的安卓支持是实验的。
The process.platform
property returns a string identifying the operating
system platform on which the Node.js process is running.
Currently possible values are:
'aix'
'darwin'
'freebsd'
'linux'
'openbsd'
'sunos'
'win32'
console.log(`This platform is ${process.platform}`);
The value 'android'
may also be returned if the Node.js is built on the
Android operating system. However, Android support in Node.js
is experimental.