Skip to content
Related Articles

Related Articles

Node.js process.umask() Function

Improve Article
Save Article
Like Article
  • Last Updated : 06 Apr, 2021

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.

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!