Sanity Pioneers: Get early access to betas, extra AI credits, and a direct line to the engineering team. Apply now

spawn undefined\System32\WindowsPowerShell" error during Sanity login

8 repliesLast updated: Nov 29, 2025

Hello. Am trying to start a new sanity project using npm create sanity@latest . It installs the node packages. Then gets to the login prompts for different options(Google, Github, Email). I select any of them, but the terminal returns a wild error! Here is what it returns :? Login type Google
Opening browser at
https://api.sanity.io/v1/auth/login/google?type=listen&uuid=dfe6ead8885119fbdcfb100be38c997f&source=cli&label=DESKTOP-L0OHL9K+%2F+win32
- Waiting for browser login to complete... Press Ctrl + C to cancelnode
:events:491 throw er; // Unhandled 'error' event
^

Error: spawn undefined\System32\WindowsPowerShell\v1.0\powershell ENOENT
at ChildProcess._handle.onexit (node
:internal/child_process:283:19) at onErrorNT (node
:internal/child_process:476:16) at process.processTicksAndRejections (node
:internal/process/task_queues:82:21)Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node
:internal/child_process:289:12) at onErrorNT (node
:internal/child_process:476:16) at process.processTicksAndRejections (node
:internal/process/task_queues:82:21) { errno: -4058,
code: 'ENOENT',
syscall: 'spawn undefined\\System32\\WindowsPowerShell\\v1.0\\powershell',
path: 'undefined\\System32\\WindowsPowerShell\\v1.0\\powershell',
spawnargs: [
'-NoProfile',
'-NonInteractive',
'–ExecutionPolicy',
'Bypass',
'-EncodedCommand',
'UwB0AGEAcgB0ACAAIgBoAHQAdABwAHMAOgAvAC8AYQBwAGkALgBzAGEAbgBpAHQAeQAuAGkAbwAvAHYAMQAvAGEAdQB0AGgALwBsAG8AZwBpAG4ALwBnAG8AbwBnAGwAZQA/AHQAeQBwAGUAPQBsAGkAcwB0AGUAbgAmAHUAdQBpAGQAPQBkAGYAZQA2AGUAYQBkADgAOAA4ADUAMQAxADkAZgBiAGQAYwBmAGIAMQAwADAAYgBlADMAOABjADkAOQA3AGYAJgBzAG8AdQByAGMAZQA9AGMAbABpACYAbABhAGIAZQBsAD0ARABFAFMASwBUAE8AUAAtAEwAMABPAEgATAA5AEsAKwAlADIARgArAHcAaQBuADMAMgAiAA=='
]
}

Node.js v18.12.1
AI Update

This is a Windows-specific environment variable issue where the Sanity CLI can't find PowerShell because the SystemRoot environment variable is undefined or missing. The error spawn undefined\System32\WindowsPowerShell\v1.0\powershell ENOENT shows that it's trying to construct the path to PowerShell but getting "undefined" instead of C:\Windows.

Here are the solutions to fix this:

Solution 1: Set the SystemRoot environment variable

The SystemRoot environment variable is missing or not accessible. You need to set it:

Solution 2: Use the login URL manually

If the above doesn't work, you can manually authenticate:

Solution 3: Try a different terminal

Sometimes this is terminal-specific. Try using:

Solution 4: Update Node.js

You're running Node.js v18.12.1. Try updating to a more recent Node.js version (Node 20+ is now recommended for Sanity Studio v4). Sometimes environment variable handling is improved in newer Node versions.

Solution 5: Check environment variables manually

Verify your environment variables are intact:

The root cause is that the Sanity CLI uses the open package to launch your browser for authentication, which on Windows tries to use PowerShell, but it can't construct the correct path without the SystemRoot variable. Solution 1 is usually the quickest fix!

Show original thread
8 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions