The path module creates portable file paths across operating systems.
Use path.join() or path.resolve() instead of manually concatenating paths. If a path comes from a user, validate it carefully to prevent path traversal.
Deep dive
join vs resolve
path.join() combines path segments. path.resolve() produces an absolute path based on the current working directory and supplied segments.
Why manual concatenation is risky
Different operating systems use different path separators. The path module handles these platform differences for you.