Reputation: 925
I'm using Node.js' path.join()
to generate the path in Windows.
const path = require('path');
const myDestPath = path.join('/D', 'test.txt'); // D drive
This results in C:\D\test.txt
, prepending the current working directory's drive letter (C:\
) automatically, which is not what I want.
How do I go about setting the different drive letter other than C:\
in Node.js?
I've tried path.resolve()
as well, but got the same result.
Upvotes: 1
Views: 2480
Reputation: 1525
You may need to add extra slash to create path
const path = require('path');
const myDestPath = path.join('D:\\', 'test.txt'); // D drive
console.log(myDestPath)
results in D:\test.txt
Upvotes: 2