๐ Directory locations
May 30, 2021 ยท View on GitHub
Typical directory locations are OS-specific.
Temporary directory
The main temporary directory could for example be:
/tmpon Linux./var/folders/.../Ton Mac.C:\Users\USER\AppData\Local\Tempon Windows.
os.tmpdir() can be used to
retrieve it on any OS.
Different terminal sessions on the same machine might have different temporary directories on Windows.
Home directory
The user's home directory could for example be:
/home/USERon Linux./Users/USERon Mac.C:\Users\USERon Windows.
os.homedir() can be used to
retrieve it on any OS.
Application-specific settings are stored into
subdirectories on Windows:
Roaming (APPDATA environment variable) and Local (LOCALAPPDATA
environment variable).
Cache directory
This is also OS-specific.
global-cache-dir can be used to
retrieve it on any OS.
Null device
This is /dev/null on Unix and \\.\nul on Windows.
os.devNull can be used to
retrieve it on any OS.
Other directories
env-paths can be used to retrieve
other common directories for logging, configuration or application data on any
OS.
Man pages
Man pages are Unix-specific so the
package.json's man field
does not have any effects on Windows.
Summary
Use os.tmpdir(),
os.homedir(),
global-cache-dir and
env-paths.