Open In App

Node.js process.umask() Function

Improve
Improve
Like Article
Like
Save
Share
Report

The process object is a global that provides information about, and control over, the current Node.js process. As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require() function.

process.umask(mask) sets the Node.js process’s file mode creation mask. Child processes inherit the mask from the parent process. Returns the previous mask.

Syntax:

process.umask()

Parameters: This method takes the following argument as a parameter.

  • String
  • Integer

Return Value: It returns a string or integer.

Note:process.unmask() has been deprecated.

Below examples illustrate the use of the process.umask(mask) property in Node.js:

Example:

index.js




// Node.js program to demonstrate the  
// process.umask(mask) Property  
       
// Include process module  
const process = require('process');  
      
const newmask = 0o022;
const oldmask = process.umask(newmask);
  
// Printing process.umask(mask) property value  
console.log(
  `Changed umask from ${oldmask.toString(8)} to ${newmask.toString(8)}`
);


Command to run:

node index.js

Output:

Changed umask from 2 to 22

Note: The above program will compile and run by using the node index.js command.

Reference: https://nodejs.org/api/process.html#process_process_umask_mask


Last Updated : 31 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads