David Trejo's Thoughts

Archive for

December 2011

How to detect that node.js is running on Windows

Do something like this:

if (process.platform === 'win32') {
  console.log('This is windows');
} else {
  console.log('%s is not windows, I hope!', process.platform);
}

Needed this to update run.js to work on Windows. Still not done making it work, but sometime soon it will happen.

The main reason I need to do this is because fs.watchFile works on Mac/Linux, but only fs.watch works on windows. Once I have it working correctly I'll post an update with code.

Cheers!
David