Installation on Windows 11 Failing because of esbuild issue

Hi there, I’m trying to install Observable with npm init "@observablehq" but running into an error. I have tried

  1. Closing other programmes
  2. Clearing npm Cache with --force
  3. Running PowerShell as an Administrator
  4. Checking for Node.js and npm updates
  5. Manually installing esbuild before running npm init "@observablehq" again
  6. Using Command Prompt instead of PowerShell
    to no avail.

Here is the error I’m getting:
`npm WARN cleanup Failed to remove some directories [
npm WARN cleanup [
npm WARN cleanup ‘C:\Users\user\AppData\Local\npm-cache\_npx\f417d01c081ec748\node_modules\js-yaml’,
npm WARN cleanup [Error: EPERM: operation not permitted, rmdir ‘C:\Users\user\AppData\Local\npm-cache_npx\f417d01c081ec748\node_modules\js-yaml’] {
npm WARN cleanup errno: -4048,
npm WARN cleanup code: ‘EPERM’,
npm WARN cleanup syscall: ‘rmdir’,
npm WARN cleanup path: ‘C:\Users\user\AppData\Local\npm-cache\_npx\f417d01c081ec748\node_modules\js-yaml’
npm WARN cleanup }
npm WARN cleanup ],
npm WARN cleanup [
npm WARN cleanup ‘C:\Users\user\AppData\Local\npm-cache\_npx\f417d01c081ec748\node_modules\resolve’,
npm WARN cleanup [Error: EPERM: operation not permitted, rmdir ‘C:\Users\user\AppData\Local\npm-cache_npx\f417d01c081ec748\node_modules\resolve\test\resolver\symlinked’] {
npm WARN cleanup errno: -4048,
npm WARN cleanup code: ‘EPERM’,
npm WARN cleanup syscall: ‘rmdir’,
npm WARN cleanup path: ‘C:\Users\user\AppData\Local\npm-cache\_npx\f417d01c081ec748\node_modules\resolve\test\resolver\symlinked’
npm WARN cleanup }
npm WARN cleanup ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path C:\Users\user\AppData\Local\npm-cache_npx\f417d01c081ec748\node_modules\tsx\node_modules\esbuild
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js
npm ERR! node:internal/errors:932
npm ERR! const err = new Error(message);
npm ERR! ^
npm ERR!
npm ERR! Error: Command failed: C:\Program Files\nodejs\node.exe C:\Users\user\AppData\Local\npm-cache_npx\f417d01c081ec748\node_modules\tsx\node_modules\esbuild\bin\esbuild --version
npm ERR! node:child_process:929
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! <ref *1> Error: spawnSync C:\Users\user\AppData\Local\npm-cache_npx\f417d01c081ec748\node_modules\tsx\node_modules@esbuild\win32-x64\esbuild.exe UNKNOWN
npm ERR! at Object.spawnSync (node:internal/child_process:1124:20)
npm ERR! at spawnSync (node:child_process:876:24)
npm ERR! at Object.execFileSync (node:child_process:919:15)
npm ERR! at Object. (C:\Users\user\AppData\Local\npm-cache_npx\f417d01c081ec748\node_modules\tsx\node_modules\esbuild\bin\esbuild:221:28)
npm ERR! at Module._compile (node:internal/modules/cjs/loader:1376:14)
npm ERR! at Module._extensions…js (node:internal/modules/cjs/loader:1435:10)
npm ERR! at Module.load (node:internal/modules/cjs/loader:1207:32)
npm ERR! at Module._load (node:internal/modules/cjs/loader:1023:12)
npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
npm ERR! at node:internal/main/run_main_module:28:49 {
npm ERR! errno: -4094,
npm ERR! code: ‘UNKNOWN’,
npm ERR! syscall: ‘spawnSync C:\Users\user\AppData\Local\npm-cache\_npx\f417d01c081ec748\node_modules\tsx\node_modules\@esbuild\win32-x64\esbuild.exe’,
npm ERR! path: ‘C:\Users\user\AppData\Local\npm-cache\_npx\f417d01c081ec748\node_modules\tsx\node_modules\@esbuild\win32-x64\esbuild.exe’,
npm ERR! spawnargs: [ ‘–version’ ],
npm ERR! error: [Circular *1],
npm ERR! status: null,
npm ERR! signal: null,
npm ERR! output: null,
npm ERR! pid: 0,
npm ERR! stdout: null,
npm ERR! stderr: null
npm ERR! }
npm ERR!
npm ERR! Node.js v20.10.0
npm ERR!
npm ERR! at checkExecSyncError (node:child_process:890:11)
npm ERR! at Object.execFileSync (node:child_process:926:15)
npm ERR! at validateBinaryVersion (C:\Users\user\AppData\Local\npm-cache_npx\f417d01c081ec748\node_modules\tsx\node_modules\esbuild\install.js:99:28)
npm ERR! at C:\Users\user\AppData\Local\npm-cache_npx\f417d01c081ec748\node_modules\tsx\node_modules\esbuild\install.js:284:5 {
npm ERR! status: 1,
npm ERR! signal: null,
npm ERR! output: [
npm ERR! null,
npm ERR! Buffer(0) [Uint8Array] ,
npm ERR! Buffer(1447) [Uint8Array] [
npm ERR! 110, 111, 100, 101, 58, 99, 104, 105, 108, 100, 95, 112,
npm ERR! 114, 111, 99, 101, 115, 115, 58, 57, 50, 57, 13, 10,
npm ERR! 32, 32, 32, 32, 116, 104, 114, 111, 119, 32, 101, 114,
npm ERR! 114, 59, 13, 10, 32, 32, 32, 32, 94, 13, 10, 13,
npm ERR! 10, 60, 114, 101, 102, 32, 42, 49, 62, 32, 69, 114,
npm ERR! 114, 111, 114, 58, 32, 115, 112, 97, 119, 110, 83, 121,
npm ERR! 110, 99, 32, 67, 58, 92, 85, 115, 101, 114, 115, 92,
npm ERR! 122, 122, 104, 104, 97, 92, 65, 112, 112, 68, 97, 116,
npm ERR! 97, 92, 76, 111,
npm ERR! … 1347 more items
npm ERR! ]
npm ERR! ],
npm ERR! pid: 9812,
npm ERR! stdout: Buffer(0) [Uint8Array] ,
npm ERR! stderr: Buffer(1447) [Uint8Array] [
npm ERR! 110, 111, 100, 101, 58, 99, 104, 105, 108, 100, 95, 112,
npm ERR! 114, 111, 99, 101, 115, 115, 58, 57, 50, 57, 13, 10,
npm ERR! 32, 32, 32, 32, 116, 104, 114, 111, 119, 32, 101, 114,
npm ERR! 114, 59, 13, 10, 32, 32, 32, 32, 94, 13, 10, 13,
npm ERR! 10, 60, 114, 101, 102, 32, 42, 49, 62, 32, 69, 114,
npm ERR! 114, 111, 114, 58, 32, 115, 112, 97, 119, 110, 83, 121,
npm ERR! 110, 99, 32, 67, 58, 92, 85, 115, 101, 114, 115, 92,
npm ERR! 122, 122, 104, 104, 97, 92, 65, 112, 112, 68, 97, 116,
npm ERR! 97, 92, 76, 111,
npm ERR! … 1347 more items
npm ERR! ]
npm ERR! }
npm ERR!
npm ERR! Node.js v20.10.0

npm ERR! A complete log of this run can be found in: C:\Users\user\AppData\Local\npm-cache_logs\2024-03-26T10_52_11_377Z-debug-0.log`

Has anyone seen something like this before, or have other troubleshooting ideas? Thanks!

This was fixed with npx clear-npx-cache, thanks to answer on Github.