Skip to content

doc: update os.tmpdir() to discuss symlink results on macOS #31877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/api/os.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,18 @@ changes:
Returns the operating system's default directory for temporary files as a
string.

By default on macOS, the returned path is a symlink. To get the resolved path,
use [`fs.realpath()`][] or [`fs.realpathSync()`][].

```js
const tmpdirPath = os.tmpdir();

// For most use cases, it does not matter whether tmpdirPath is a symlink or not
// but if it does matter, obtain a resolved path with fs.realpath() or
// fs.realpathSync().
const tmpdirResolvedPath = fs.realpathSync(tmpdirPath);
```

## `os.totalmem()`
<!-- YAML
added: v0.3.3
Expand Down Expand Up @@ -1252,6 +1264,8 @@ The following process scheduling constants are exported by
</table>

[`SystemError`]: errors.html#errors_class_systemerror
[`fs.realpath()`]: fs.html#fs_fs_realpath_path_options_callback
[`fs.realpathSync()`]: fs.html#fs_fs_realpathsync_path_options
[`process.arch`]: process.html#process_process_arch
[`process.platform`]: process.html#process_process_platform
[Android building]: https://github.com/nodejs/node/blob/master/BUILDING.md#androidandroid-based-devices-eg-firefox-os
Expand Down