Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js fs module and windows paths

Does the Node.js fs module implicitly convert Windows folder path separators from '\\' to '/'?

For example, if I use this call on Windows:

fs.readdirSync(dir).forEach(function(file) {

});

file argument has '/' path separators, not '\\', why is that?

like image 237
Alexander Mills Avatar asked Aug 06 '15 05:08

Alexander Mills


1 Answers

Yes it does. See more: Writing cross-platform Node.js

Be sure to use path.join and path.normalize instead of having explicit path separators (/, \, \\, etc) in your code.

like image 126
krl Avatar answered Oct 01 '22 18:10

krl