Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7020681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:20:59+00:00 2026-05-27T23:20:59+00:00

How do I use chmod with Node.js? There is a method in the package

  • 0

How do I use chmod with Node.js?

There is a method in the package fs, which should do this, but I don’t know what it takes as the second argument.

fs.chmod(path, mode, [callback])

Asynchronous chmod(2). No arguments other than a possible exception are given to the completion callback.

fs.chmodSync(path, mode)

Synchronous chmod(2).

(from the Node.js documentation)

If I do something like

fs.chmodSync('test', 0755);

nothing happens (the file isn’t changed to that mode).

fs.chmodSync('test', '+x');

doesn’t work either.

I’m working on a Windows machine btw.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:21:00+00:00Added an answer on May 27, 2026 at 11:21 pm

    According to its sourcecode /lib/fs.js on line 508:

    fs.chmodSync = function(path, mode) {
      return binding.chmod(pathModule._makeLong(path), modeNum(mode));
    };
    

    and line 203:

    function modeNum(m, def) {
      switch (typeof m) {
        case 'number': return m;
        case 'string': return parseInt(m, 8);
        default:
          if (def) {
            return modeNum(def);
          } else {
            return undefined;
          }
      }
    }
    

    it takes either an octal number or a string.

    e.g.

    fs.chmodSync('test', 0755);
    fs.chmodSync('test', '755');
    

    It doesn’t work in your case because the file modes only exist on *nix machines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

use this website a lot but first time posting. My program creates a number
I needed to learn node.js and mongodb which requires me to use my mac
I wanted to change the file permission when I use git, but the chmod
When I use chmod() to change permissions at run time, it gives me the
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Whenever we use chmod, we set different authorities to different users types like owner,
I am trying to use os.chmod to set directory permissions to ensure the webserver
I'm trying to use PHP to create a file, but it isn't working. I
how can I change file/folders permissions on Microsoft IIS ? Should I use icacls
I need to use chmod to change all files recursivly to 664. I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.