I've been trying to install the diskusage node_module and I keep getting errors. I've followed links and have come up with nothing.
Here is the result after running npm install diskusage:
C:\...\project>npm install diskusage
npm ERR! code 1
npm ERR! path C:\Users\user\Documents\project\node_modules\diskusage
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.13.0 found at "C:\Users\user\AppData\Local\Programs\Python\Python313\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS not looking for VS2015 as it is only supported up to Node.js 18
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (C:\Users\user\Documents\project\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack at C:\Users\user\Documents\project\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Users\user\Documents\project\node_modules\node-gyp\lib\find-visualstudio.js:380:14)
npm ERR! gyp ERR! stack at C:\Users\user\Documents\project\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2015 (C:\Users\user\Documents\github\project\node_modules\node-gyp\lib\find-visualstudio.js:364:14)
npm ERR! gyp ERR! stack at C:\Users\user\Documents\project\node_modules\node-gyp\lib\find-visualstudio.js:67:12
npm ERR! gyp ERR! stack at failPowershell (C:\Users\user\Documents\project\node_modules\node-gyp\lib\find-visualstudio.js:156:7)
npm ERR! gyp ERR! stack at VisualStudioFinder.parseData (C:\Users\user\Documents\project\node_modules\node-gyp\lib\find-visualstudio.js:170:14)
npm ERR! gyp ERR! stack at C:\Users\user\Documents\project\node_modules\node-gyp\lib\find-visualstudio.js:143:14
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:414:7)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:518:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1105:16)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm ERR! gyp ERR! System Windows_NT 10.0.22000
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\Documents\\project\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\user\Documents\project\node_modules\diskusage
npm ERR! gyp ERR! node -v v20.11.1
npm ERR! gyp ERR! node-gyp -v v9.4.1
npm ERR! gyp ERR! not ok
My project is a nodejs express project that has run in vscode before. I'm doing a reinstall and now it's asking where Visual Studio is.
I don't know how to fix those errors.
Regarding installing Visual Studio to fix the issues:
Installing Desktop Development with C++ workload

UPDATE:
Installed Visual Studio and that got rid of one error message and now I'm getting this error in the console:
PS C:\Users\user\Documents\project> npm install diskusage
npm ERR! code 1
npm ERR! path C:\Users\user\Documents\project\node_modules\diskusage
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.13.0 found at "C:\Users\user\AppData\Local\Programs\Python\Python313\python.exe"
npm ERR! gyp info find VS using VS2022 (17.9.34714.143) found at:
npm ERR! gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\user\AppData\Local\Programs\Python\Python313\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args 'C:\\Users\\user\\Documents\\project\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'msvs',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\Users\\user\\Documents\\project\\node_modules\\diskusage\\build\\config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\Users\\user\\Documents\\project\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\Users\\user\\AppData\\Local\\node-gyp\\Cache\\20.11.1\\include\\node\\common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=C:\\Users\\user\\AppData\\Local\\node-gyp\\Cache\\20.11.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=C:\\Users\\user\\Documents\\project\\node_modules\\node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\user\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\20.11.1\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=C:\\Users\\user\\Documents\\project\\node_modules\\diskusage',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'C:\\Users\\user\\Documents\\project\\node_modules\\diskusage\\build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Traceback (most recent call last):
npm ERR! File "C:\Users\user\Documents\project\node_modules\node-gyp\gyp\gyp_main.py", line 42, in <module>
npm ERR! import gyp # noqa: E402
npm ERR! ^^^^^^^^^^
npm ERR! File "C:\Users\user\Documents\project\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 9, in <module>
npm ERR! import gyp.input
npm ERR! File "C:\Users\user\Documents\project\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 19, in <module>
npm ERR! from distutils.version import StrictVersion
npm ERR! ModuleNotFoundError: No module named 'distutils'
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (C:\Users\user\Documents\project\node_modules\node-gyp\lib\configure.js:325:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:518:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Windows_NT 10.0.22000
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\Documents\\project\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\user\Documents\project\node_modules\diskusage
npm ERR! gyp ERR! node -v v20.11.1
npm ERR! gyp ERR! node-gyp -v v9.4.1
npm ERR! gyp ERR! not ok
What the f going on? Why is this giving me so much trouble? This isn't the first error. First python, then directory can't be removed, then command failed, then install visual studio, then missing module diskutils. Why is this library giving me so much trouble (update it's not just this library)? Isn't npm supposed to handle all of this? Shouldn't npm install the things it needs to function? If you run an npm installer and then npm fails more than 4 times asking where missing items are when trying to install a library then is it installed?
If this is related to the library itself, and this is the normal install process, how can I avoid node modules like this?
Maybe on the npmjs.com site the library should say "must be compiled from source" and so it "needs visual studio" installed or "needs python installed".
Solution Update:
I downgraded to Python 3.11 because it was mentioned that the tools / commands mentioned in the errors above were removed from newer versions of python and then I also opened a terminal window (not in vscode but a cmd / powershell and ran as administrator) and then ran npm install diskusage and the error has gone away and everything seems to be in order.
I don't know what action fixed the issue because I did two things at once. I'm guessing both were needed (to remove the can't remove directory) and the python install errors of can't install because of missing commands.
Looks like the
diskusagepackage needs some extra tools to install itself. I assume that it needs Visual Studio.Either install the Full Monty (Visual Studio). This is what the error message recommends. It will give you everything you need for
diskusageand other development projects. You can download it from the official Microsoft website.Go Lighter (Build Tools for Visual Studio). If you don't want the whole shebang of Visual Studio, you can just grab the "Build Tools" part. This has the necessary bits of
diskusageneeds. You can find these tools on the same Microsoft download page.Once you've got either of those installed, just run the
npm install diskusagecommand again and it should find the missing pieces and install happily.Before that, try to double-check that your Node.js version works with
diskusage. You can find compatibility info in thediskusagedocumentation (usually online).If things still go wrong after installing Visual Studio stuff, try adding the
--loglevel silly flagto thenpm install diskusagecommand. This gives you more detailed error messages that might help troubleshoot further.This should help you to get
diskusageup and running in no time.