简体   繁体   中英

Format a drive in node.js

I'm working on a project in node.js and I'm stuck at this. I need to convert an external device ( a usb stick etc.) into an "exFAT" partition if it's not an exFAT . I used an npm package called "drivelist-scanner" to get the list of usb devices connected and also their mountpoints. Now the only thing left to do is to convert them into exFAT and I don't know how to do it. I came across an npm package called "gpt" which said it can format drives but the documentation is not so clear. Here's a link to the github repository for gpt : Github link

Any ideas on how to accomplish this? I'm even willing to launch a script based on the operating system to do the job, but I'm not sure on how to do this too. Any help is appreciated. Thanks.

Actually you can not directly format a drive with programming languages. You will need to invoke a operating system specific program to do the actual work for you.

Create a bash script

You can use this info for do that.

https://superuser.com/questions/274687/how-do-i-format-a-usb-drive-on-a-pc-that-was-formatted-on-a-mac

Run a bash script with node.js

You can use exec command for run a bash script with node.js

Run shell script with node.js (childProcess)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM