Last Updated: September 27, 2021
·
23.42K
· thierrylemoulec

Get home directory in nodejs

You can get a user home directory with node using process.env['HOME'] at least it worked for me on osx.

3 Responses
Add your response

Works in linux too. process.env['USERPROFILE'] would do the same in windows.

over 1 year ago ·

Great to know thanks

over 1 year ago ·

process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE should cover all bases

over 1 year ago ·