I have a script, which is using standard node.js path modules https://nodejs.org/api/path.html
When using path functions such as 'path.relative', the path library looks at what operating system I'm on, and uses that OS's path separator. (\ on Windows, / on POSIX). That's cool, and makes a lot of tasks very convenient. The problem is, the script is auto-generating some files which are intended for a UNIX platform, and need the Unix path separator. But sometimes the script will be being run from a Windows platform. I need the output of the script to be the same (Unix path separators), regardless of which platform is running the script. Is there a way to do this? (To make path use a specific path separator, rather than using the one for the operating system running Node?)
You should be able to use path.posix instead of just path.
Example:
var path = require('path');
path.join('a', 'b'); // a\\b
path.posix.join('a', 'b'); // a/b
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With