Skip to content

fs.appendFileSync does not accept a number type in data argument node v14 #33213

Description

@ykhedher
  • Version: 14.1.0
  • Platform: Windows 10
  • Subsystem: none
  • error: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (7)

this is the code:

const fs = require('fs')

fs.writeFileSync('notes.txt', 'NODEJS')


fs.appendFileSync('notes.txt', 7 )

I expected to get a file with: NODEJS7
I got : NODEJS

Activity

  1. mscdex commented on May 2, 2020

    @mscdex
    Contributor

    Seems like the correct behavior to me. Are you saying this worked in a previous version?

  2. devsnek commented on May 2, 2020

    @devsnek
    Member

    This isn't a bug, the validation was tightened up. See #31030.

  3. added
    fsIssues and PRs related to file-system APIs and the fs module.
    on May 2, 2020
  4. ykhedher commented on May 6, 2020

    @ykhedher
    Author

    Seems like the correct behavior to me. Are you saying this worked in a previous version?

    YES actually I created a NODE COURSE, I was using node v13 but some students using node v14 got this issue so upgraded node and I got the same issue.

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

    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