【发布时间】:2019-07-14 14:47:44
【问题描述】:
我查看了How do I determine the current operating system with Node.js 和类似的帖子,但尚未找到解决方案。
我在 Windows 7 上使用 Docker。这种情况是独一无二的,因为在我的设置下,我必须在配置 webpack 开发服务器代理请求时使用我的本地 IP。这与项目中使用 Windows 10 或 Mac 的其他开发人员不同,他们能够代理 localhost。
This answer comes close,但是有条件地检查 isWindows 还不够好。我需要检查isWindows7。我已经尝试过这些,但我没有看到任何东西(AFAIK)足以证明我使用的是 Windows 7:
const os = require('os');
console.log(os.platform());
console.log(os.type());
console.log(os.release());
console.log(os.arch());
console.log(os.hostname());
【问题讨论】: