I just upgraded Node.js to v20.16.0 on my Windows 11 machine and tried to install Netlify CLI with the npm install netlify-cli -g
command, but the installation failed:
npm warn deprecated glob@8.1.0: Glob versions prior to v9 are no longer supported
npm warn cleanup Failed to remove some directories [
npm warn cleanup [
npm warn cleanup 'C:\\Users\\Senpai\\AppData\\Roaming\\npm\\node_modules\\netlify-cli\\node_modules\\sharp',
npm warn cleanup [Error: EPERM: operation not permitted, rmdir 'C:\Users\Senpai\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\sharp\vendor\8.14.5\win32-x64'] {
npm warn cleanup errno: -4048,
npm warn cleanup code: 'EPERM',
npm warn cleanup syscall: 'rmdir',
npm warn cleanup path: 'C:\\Users\\Senpai\\AppData\\Roaming\\npm\\node_modules\\netlify-cli\\node_modules\\sharp\\vendor\\8.14.5\\win32-x64'
npm warn cleanup }
npm warn cleanup ],
npm warn cleanup [
npm warn cleanup 'C:\\Users\\Senpai\\AppData\\Roaming\\npm\\node_modules',
npm warn cleanup [Error: EPERM: operation not permitted, rmdir 'C:\Users\Senpai\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\@netlify\edge-bundler\deno'] {
npm warn cleanup errno: -4048,
npm warn cleanup code: 'EPERM',
npm warn cleanup syscall: 'rmdir',
npm warn cleanup path: 'C:\\Users\\Senpai\\AppData\\Roaming\\npm\\node_modules\\netlify-cli\\node_modules\\@netlify\\edge-bundler\\deno'
npm warn cleanup }
npm warn cleanup ]
npm warn cleanup ]
npm error code 1
npm error path C:\Users\Senpai\AppData\Roaming\npm\node_modules\netlify-cli
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c node ./scripts/postinstall.js
npm error node:internal/fs/promises:1169
npm error return await PromisePrototypeThen(
npm error ^
npm error
npm error Error: EISDIR: illegal operation on a directory, realpath 'R:\Temp'
npm error at async Object.realpath (node:internal/fs/promises:1169:10)
npm error at async file:///C:/Users/Senpai/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/temp-dir/index.js:4:28 {
npm error errno: -4068,
npm error code: 'EISDIR',
npm error syscall: 'realpath',
npm error path: 'R:\\Temp'
npm error }
npm error
npm error Node.js v20.16.0
npm notice
npm notice New patch version of npm available! 10.8.1 -> 10.8.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.2
npm notice To update run: npm install -g npm@10.8.2
npm notice
npm error A complete log of this run can be found in: C:\Users\Senpai\AppData\Local\npm-cache\_logs\2024-08-19T05_25_24_126Z-debug-0.log
Full log:
2024-08-19T05_25_24_126Z-debug-0.zip (47.0 KB)
Then, when I try to run the netlify
command anyway, I get:
node:internal/modules/cjs/loader:1148
throw err;
^
Error: Cannot find module 'C:\Users\Senpai\AppData\Roaming\npm\node_modules\netlify-cli\bin\run.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.16.0
Any ideas?
Also, I just tried to run npm uninstall netlify-cli -g
to get rid of the corrupted installation, but even though it no longer shows up with a npm list -g --depth=0
, the netlify
command still executes! Note that it still returns the same error as before.
How to I fix this and/or clean my corrupted installation?
@SmashManiac This probably doesn’t help much, but I’ve just tested installation of the Netlify CLI on Windows 11 and did not encounter the issue.
I was also able to uninstall and reinstall with no issue.
I don’t use windows for development so I can’t provide a foolproof solution, (perhaps someone else can).
To try and fix your ‘corrupted’ installation you could check the npm global installation directory that it mentions in the error message:
C:\Users\Senpai\AppData\Roaming\npm\node_modules\
If there were files left over from the install they would be at:
C:\Users\Senpai\AppData\Roaming\npm\node_modules\netlify-cli\
You could just delete that entire netlify-cli
directory.
My node_modules
directory was already empty from my previous uninstallation attempt. I just double-checked to be sure.
However, that made me realize that the netlify
scripts were installed in the parent npm
directory, which had been added to my PATH environment variable as well. I just deleted the entire npm
directory and cleaned my PATH, and everything looks good now, assuming no other files were installed elsewhere.
I’m still wondering why the installation failed in the first place though. I’m unable to use Netlify CLI due to this.
As mentioned, I don’t use Windows for development, so cannot elucidate.
Out of interest, are you able to install other npm packages globally?
What about other similar CLI’s?
What about Vercel’s?
Yes, other npm packages install globally without any issues on my machine. I just tried installing JQuery that way as a test and it works fine. I never ran into any issues with cloud-management CLIs in the past either, such as AWS CLI.
Great, thanks for the additional detail, I was just confirming since obviously if other packages failed too it would point to a wider issue.
For anyone else that encounters this thread, I couldn’t replicate the issue with node v20.16.0
, npm 10.8.1
on Windows 11 Home
.
Running npm i netlify-cli -g
installed netlify-cli 17.34.2
The system I tested on is usually only used for gaming, and I installed node
with the Prebuilt Installer.
The only related reference in Path
on my system was:
C:\Users\me\AppData\Roaming\npm\node_modules\
I also confirmed that running the cli worked.
@SmashManiac Since other CLI’s work for you, if you’re confident there’s an issue with the Netlify one you could report it as an issue against the repository here:
You can also install CLI locally in a project. Just run npm i netlify-cli
. Doesn’t have to be a global install.
Unfortunately local installation doesn’t work either. I still get Error: EISDIR: illegal operation on a directory, realpath 'R:\Temp'
error at node:internal/fs/promises:1169
in ./scripts/postinstall.js
, and nothing gets installed.
The permissions on your device has been somehow messed up. Have you tried using WSL? Or a different user account in Windows?
The same thing had happened to me on a mac once and was fixed once I reset the device. I didn’t know about this article back then: Resolving EACCES permissions errors when installing packages globally | npm Docs, but maybe that helps in your case?
I’m the administrator and only user on my machine, the node_modules
directory is empty before I attempt the installation, and other npm
installations work just fine as I previously mentioned. Therefore, whatever’s happening that’s causing this permission issue can only occur WHILE npm
is executing, unless some other silent error is also happening beforehand.
Also, according to the logs, a syscall to realpath
was attempted. Why would a Linux syscall be attempted at all while the script is running on a Windows machine? That makes no sense, and I think Netlify should investigate this.
As for using WSL as a workaround, assuming I wouldn’t run into any other unexpected issues, the main problem is that file I/O between WSL and the host machine is extremely inefficient, and to workaround that WSL limitation, I would also need to completely change my dev environment and workflow along with some Windows-specific code in my project, and then be stuck working in a different IDE than my preferred one. As such, it may be a good idea, but it’s not worth the trouble in my case.