Error installing Sanity via npm on terminal

10 replies
Last updated: Feb 23, 2023
đź‘‹ Hello, team!
I'm new to sanity and am having error installing sanity through npm on my terminal
AI Update

Welcome to Sanity! đź‘‹ Happy to help you get started. Without knowing the specific error you're encountering, let me cover the most common installation issues and the proper way to install Sanity in 2025.

The Modern Way to Install Sanity

The recommended approach is now to use npm create sanity@latest rather than installing the CLI globally:

npm create sanity@latest

This command will guide you through an interactive setup process to create a new Sanity project, including authentication, project creation, dataset configuration, and template selection.

Common Installation Issues & Solutions

1. Node.js Version Requirements

The most common issue is using an outdated Node.js version. Sanity Studio v4 requires Node.js 20 or higher. Check your version:

node -v

If you're on an older version, download and install Node.js 20+ from nodejs.org.

2. Permission Errors (EACCES)

If you see permission errors when installing globally, avoid using sudo. Instead, configure npm to use a different directory or use a Node version manager like nvm.

3. Network/Registry Issues

If npm is timing out or having trouble connecting, try:

npm config set registry https://registry.npmjs.org/

4. Cache Issues

Sometimes clearing the npm cache helps:

npm cache clean --force

Alternative Installation Methods

If npm create sanity@latest doesn't work, you can also try:

Using npx (no installation needed):

npx -y sanity@latest init

Or install the CLI globally first:

npm install --global sanity@latest
sanity init

As detailed in the Sanity CLI documentation, the sanity init command provides options for unattended mode (-y), specifying project and dataset names, choosing templates, and more.

Next Steps

Once installation succeeds, you can start your development server with:

npm run dev

Could you share the specific error message you're seeing? That would help pinpoint the exact issue. Common error messages include things like "EACCES", "command not found", "unsupported engine", or network timeouts. With the actual error, I or others in the community can provide more targeted help!

Show original thread
10 replies
Hello and welcome!!!
What’s the error you are running into?
This is the error


? Login type GitHub

Opening browser at
https://api.sanity.io/v1/auth/login/github?type=listen&uuid=a912a197d93723af3be6e3f554f62a79&source=cli&label=octseven+%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)PS C:\Users\hp\Desktop\Sanity\backend> npm create sanity@latest -- --template clean --create-project "Sanity Project" --dataset production
You're setting up a new project!
We'll make sure you have an account with
Sanity.io . Then we'llinstall an open-source JS content editor that connects to
the real-time hosted API on
Sanity.io . Hang on.
Press ctrl + C at any time to quit.

Prefer web interfaces to terminals?
You can also set up best practice Sanity projects with
your favorite frontends on
https://www.sanity.io/templates
We can't find any auth credentials in your Sanity config
- log in or create a new account
Thanks for sending that over.

I think it’s regarding this:
We can’t find any auth credentials in your Sanity config
- log in or create a new account
It looks like you need to setup your Sanity CLI and setup a sanity account at
Sanity.io

Docs:
https://www.sanity.io/docs/getting-started-with-sanity-cli
I'm also having trouble with this for hours. I read that it was a windows path error and been trying still can't seem to fix it, I tried following the instructions someone said in a previous thread about this error
Isn't working have setup my sanity account and still not working
same here, I keep changing the path directory in the environment variables and have added so many paths and no luck still
Have you tried this solution?
I installed git on windows and tried running it but still have problems. I was able to login to sanity through Linux terminal though
Still having problem

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.

Was this answer helpful?