Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport for executing Node.js fs functions as sudo #35765
Comments
|
This is not likely as there are a number of usability and security concerns with doing this. It's already possible to run the node process with sudo so I'm not sure what additional benefit this would offer. |
|
@jasnell I guess it's theoretically possible with You know how the file manager on Linux prompts you with the password dialog when you're trying to open a protected directory? Let's say the user of your Node.js file manager app wants to do the same, they want to see the contents of their protected directory How do we implement this? Do you have to create a dummy Something like this, with the help of sudo-prompt module, maybe? const sudo = require('sudo-prompt')
const options = {
name: 'Electron'
}
const command = 'node "PATH_TO_THE_APP/readdir.js path/to/dir"'
sudo.exec(command, options, function(error, stdout, stderr) {
if (error) { throw error }
console.log(stdout)
})On Windows, you can't even pass If you know how to do it, please suggest a working solution for this, using existing Node.js methods |
|
Strong -1.
|
|
@devsnek unfortunately you cannot just run Electron apps as root without The only solution I can see is to use Node's If someone knows how to do it, please share a little code snippet |


Is your feature request related to a problem? Please describe.
The inability to execute Node.js
fsfunctions with sudo (as admin) limits the applications built on Node.js. Nowadays, a lot of applications are built with Electron (which comes with Node.js), This feature would allow us to build more advanced apps with Node.js.Describe the solution you'd like
Example;
asAdmin: truerequests the system password dialog:Describe alternatives you've considered
N/A