I'm tring to run vscode's codebase locally so I can contribute to it.
I'm wondering if anyone else has had a similiar problem to me, whether with VSCode or another Node project.
When I run npm install
it fails to build.
I get (right after all the "npm warn deprecated"s)
npm warn cleanup Failed to remove some directories [
npm warn cleanup [
npm warn cleanup '/Users/nathanwiseman/Documents/GitHub/vscode/node_modules/windows-foreground-love',
npm warn cleanup [Error: ENOTEMPTY: directory not empty, rmdir '/Users/.../Documents/GitHub/vscode/node_modules/windows-foreground-love'] {
npm warn cleanup errno: -66,
npm warn cleanup code: 'ENOTEMPTY',
npm warn cleanup syscall: 'rmdir',
npm warn cleanup path: '/Users/.../Documents/GitHub/vscode/node_modules/windows-foreground-love'
npm warn cleanup }
npm warn cleanup ],
... (same for the other three vscode/node_modules/ folders)
npm error code 1
npm error path /Users/.../Documents/GitHub/vscode/node_modules/@vscode/policy-watcher
npm error command failed
npm error command sh -c node-gyp rebuild
...
I tried all the tips in the contributor's guide (https://github.com/microsoft/vscode/wiki/How-to-Contribute) and I even tried with different versions of Node (18, 22, and 23). I also tried deleting the offending folders and trying again (after all the refresh tips), and I also tried renaming the folders, but those ideas didn't help either.
Please don't tell me I should be running it in a remote Docker container. That would be even more complicated for me, due to be security set-up.
I have successfully built projects with npm before on this machine. I am working out of ZShell on MacOS 15.0.1 on an Apple Silicon M2 machine.
(Edit: changed blockquote formatting of the terminal quotes to code formatting for readability)
I found my answer here: https://github.com/nodejs/node-addon-api/issues/222 (which I found through the post Google found me here: https://github.com/nodejs/node-addon-api/issues/416)
Basically, just sudo rm -rf /Library/Developer/CommandLineTools
and reinstalled from scratch (xcode-select --install
)
The critical error line was over 30 lines down:
npm error In file included from ../src/main.cc:6:
npm error ../node_modules/node-addon-api/napi.h:14:10: fatal error: 'functional' file not found
npm error 14 | #include <functional>
npm error | ^~~~~~~~~~~~
npm error 1 error generated.
npm error make: *** [Release/obj.target/vscode-policy-watcher/src/main.o] Error 1
...
Credit goes to Al Ilseman for homing in on the critical line.