Is there a method to rectify the discrepancy in node.js from Windows to Linux and Mac concerning the backslash versus forward slash?
Windows requires backslashes when calling locations in git bash
, while Mac/Linux requires forward slashes. I'm working on a project with both Mac and Windows users so I can't change all the forward slashes to backslashes in the code because when Mac users pull, coffee wont be able to properly run for them and vice versa.
Is there a solution to this?
Make sure to use path methods instead of typing out paths.
path.normalize()
andpath.join()
are particularly useful when developing cross platform:On Windows:
On Linux:
Hope this helps.
In addition to Chad answer, when you are constructing paths you can:
or