I have a website that I'm running integration tests for, on a Linux Docker (Debian).
In the website's API I do this:
UPLOADED_FILES_LOCATION="C:\Users\username\Documents\uploadedFiles"
const filePath = "folderName/fileName.jpg";
const filePath = path.join(process.env.UPLOADED_FILES_LOCATION!, filePath);
const fileBuffer = await fs.readFileSync(filePath);
Buut, I get this error during the tests:
Error: ENOENT: no such file or directory, open 'C:\Users\username\Documents\uploadedFiles/folderName\fileName.jpg'
I tried also like this:
const filePath = path.normalize(path.join(process.env.UPLOADED_FILES_LOCATION!, filePath));
And like this:
const filePath = path.normalize(`${process.env.UPLOADED_FILES_LOCATION!}/${filePath}`);
Aren't both path.normalize and path.join supposed to replace slashes (normalize the path)? Why isn't this working?
Edit: I realize the path is a Windows directory, but if you look a the path it still has mixed slashes...