Reputation:
I used the following code to access a file in my project. It worked great when the code file was located in the root folder. However, I've moved the file into the folder (utils) and now it's getting the wrong path.
var filePath = path.join(__dirname, '/test/test.txt'
);
Currently I'm getting
c://Users//i0433//WebstormProjects//Aps//utils//test//test.txt'
I need to remove utils so I can get the correct path.
c://Users//i0433//WebstormProjects//Aps//test//test.txt'
Upvotes: 2
Views: 66
Reputation: 35598
Usually in this instance adding a ..
to the beginning of the path will work:
var filePath = path.join(__dirname, '../test/test.txt');
Upvotes: 4