0001. 使用 process 模块来区分不同的操作系统
1. 💻 demos.1 - 通过 process.platform 中记录的当前平台信息来区分不同的操作系统
js
function printPlatform() {
// console.log(process.platform)
if (process.platform === 'linux') console.log('当前使用的操作系统是 Linux')
else if (process.platform === 'darwin') console.log('当前使用的操作系统是 MacOS')
else if (process.platform === 'win32') console.log('当前使用的操作系统是 Windows')
else console.log('当前使用的操作系统是未知')
}
printPlatform()
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
- 很简单也很常用的操作。