Determine if running on Windows or Linux?

How can I tell (on the server) if I’m running in Windows or Linux.

I’m developing in WIndows but then deploying to Modulus, and need to set some paths differently during testing/development.


You could try this package:

1 Like

process.platform is probably the easiest.

If you dig into the node internals, you can also use os

var platform = os.platform();
if (platform === 'freebsd' || platform === 'linux') {
  console.log("You are running linux!");
} else if (platform === 'win32') {
  console.log("You are running windows, bummer");

EDIT: of course this will only work on the server.

1 Like

Thanks, I got it working using the package suggested by Rob.