Skip to content

doc: child_process: default encoding is buffer, not string#63734

Open
coderaiser wants to merge 1 commit into
nodejs:mainfrom
coderaiser:patch-1
Open

doc: child_process: default encoding is buffer, not string#63734
coderaiser wants to merge 1 commit into
nodejs:mainfrom
coderaiser:patch-1

Conversation

@coderaiser
Copy link
Copy Markdown
Contributor

Default encoding for execSync is Buffer, not string:

import {execSync} from 'node:child_process'

console.log(typeof execSync('ls'));

console.log(execSync('ls', {
    encoding: 'utf8'
}));
$ node 1.js
node 1.js 
<Buffer 44 61 72 77 69 6e 0a>
Darwin

@nodejs-github-bot nodejs-github-bot added child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to the documentations. labels Jun 3, 2026
Signed-off-by: coderaiser <coderaiser@cloudcmd.io>
Copy link
Copy Markdown
Member

@Renegade334 Renegade334 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your PR description is correct, but that's already what the docs state. You have edited the wrong methods.

@coderaiser
Copy link
Copy Markdown
Contributor Author

what method should I edit? utf8 not set by default

@Renegade334
Copy link
Copy Markdown
Member

The docs do not need editing. The default encoding for exec is 'utf8', and the default encoding for execSync is 'buffer', as already stated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to the documentations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants