How do I determine the current operating system with Node.js

The variable to use would be process.platform

On Mac the variable is set to darwin. On Windows, it is set to win32 (even on 64 bit).

Current possible values are:

  • aix
  • darwin
  • freebsd
  • linux
  • openbsd
  • sunos
  • win32
  • android (Experimental, according to the link)

I just set this at the top of my jakeFile:

var isWin = process.platform === "win32";

Leave a Comment