process.cwd() Different paths in development and production environment #62513
Unanswered
SabrioBiblio
asked this question in
Help
Replies: 1 comment
-
Getting and using the current working directory (using process.cwd()) within the same function This issue often arises when you retrieve and use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I'm using next js 14.
In each page folder I have a file (meta.md) that I read using fs. Let it be written accordingly to these files
const postsDirectoryPath = process.cwd();
In the development environment, everything works and the files are read, this is understandable, since process.cwd refers to the root directory of the project. But on the vercel, process.cwd refers to .next, where naturally the meta.md file no longer exists. I have some problems with debugging on Vercel and I can't keep track of everything.
But there is some confusion about how this works in production, since I call my function that reads the files in the top page.tsx (homepage) file and it surprisingly works. Doesn't work if the md file reading function is called at levels below (another pages in another folders)
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions