Skip to content
Related Articles

Related Articles

Node.js process.umask() Function

Improve Article
Save Article
  • Last Updated : 31 Aug, 2022
Improve Article
Save Article

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.



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:



// 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  
  `Changed umask from ${oldmask.toString(8)} to ${newmask.toString(8)}`

Command to run:

node index.js


Changed umask from 2 to 22

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


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!