镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fs.writeFileSync doesn't change the mode of existing file. #39859

Description

@gemwuu

Version

16.4.0

Platform

macOS

Subsystem

Big Sur(11.2.3)

What steps will reproduce the bug?

echo "echo 11" > a && ls -l a && ./a
node -e "fs.writeFileSync('./a', 'echo 1111', {mode: 0o755})" && ls -l a && ./a
-rw-r--r--  1 test  staff  8 Aug 24 19:04 a
a.sh: line 1: ./a: Permission denied
-rw-r--r--  1 test  staff  9 Aug 24 19:04 a
a.sh: line 2: ./a: Permission denied

How often does it reproduce? Is there a required condition?

no condition

What is the expected behavior?

should print 1111.

What do you see instead?

a.sh: line 2: ./a: Permission denied

Additional information

No response

No activity

Activity on this issue will appear here.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.fsIssues and PRs related to file-system APIs and the fs module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions