Как получить массив всех разделов на Node.js?
Требуется получить массив всех доступных для просмотра разделов жесткого диска, как это можно сделать? При установке библиотеки driverlist выдавало ошибку.
rebuild-install WARN install No prebuilt binaries found (target=12.18.4 runtime=node arch=x64 libc= platform=win32)
E:\Важно\web\dev\rTelecomTask\webTotalCommanderFromMarEee\node_modules\drivelist>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild ) gyp ERR! find Python gyp ERR! find Python Python is not set from command line or npm configuration gyp ERR! find Python Python is not set from environment variable PYTHON gyp ERR! find Python checking if "python" can be used
Ответы (2 шт):
Можно использовать эту библиотеку.
const nodeDiskInfo = require("node-disk-info");
try {
const disks = nodeDiskInfo.getDiskInfoSync();
printResults(disks);
} catch (e) {
console.error(e);
}
function printResults(disks) {
for (const disk of disks) {
console.log("Filesystem:", disk.filesystem);
console.log("Capacity:", disk.capacity);
console.log("Mounted:", disk.mounted, "\n");
}
}
Вывод:
Filesystem: Local Fixed Disk
Capacity: 83%
Mounted: C:
Filesystem: Local Fixed Disk
Capacity: 68%
Mounted: D:
Ваша проблема в том, что вы не установили переменную среды, поэтому не устанавливается библиотека.
gyp ERR! find Python Python is not set from command line or npm configuration gyp ERR! find Python Python is not set from environment variable PYTHON
Установите переменную среды:
set PYTHON=D:\Python\bin\Python.exe
Или таким образом:
- Мой компьютер > Свойства
- Advanced > Переменные окружения
- Ищем Path и нажимаем Edit
- Кнопка "Добавить" > Добавляем путь к директории с Python > Ok



