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.

thanks
Russell

You could try this package: https://atmospherejs.com/mrt/platform.js

1 Like

process.platform is probably the easiest.

https://devdocs.io/node/process#process_process_platform

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.