Unauthorized error when running npm create sanity@latest -y command
3 replies
Last updated: May 10, 2024
G
Hi folks - running
npm create sanity@latest -y- gives unauthorized error as I am not logged in. How am I supposed to be logged in when package is not even installed?
May 10, 2024, 10:32 PM
Can you please paste a snippet of exactly what you’re seeing in the terminal? I’m not able to reproduce whether logged in or not and whether the CLI is already installed or not.
May 10, 2024, 10:39 PM
G
greggevorkyan@MacBook-Pro-6 modernbanc-sanity % npm -y create sanity@latest
You're setting up a new project!
We'll make sure you have an account with <http://Sanity.io|Sanity.io>. Then we'll
install an open-source JS content editor that connects to
the real-time hosted API on <http://Sanity.io|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>
Looks like you already have a Sanity-account. Sweet!
✖ Fetching existing projects
Error: Failed to communicate with the Sanity API:
Unauthorized - Session not found. You may need to login again with sanity login.
For more information, see <https://docs.sanity.io/help/cli-errors>.
at getOrCreateProject (~/.npm/_npx/67a0730928194b24/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:44559:29)
at async getProjectDetails (~/.npm/_npx/67a0730928194b24/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:44521:21)
at async initSanity (~/.npm/_npx/67a0730928194b24/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:44316:108)
greggevorkyan@MacBook-Pro-6 modernbanc-sanity % npm create sanity@latest -y
You're setting up a new project!
We'll make sure you have an account with <http://Sanity.io|Sanity.io>. Then we'll
install an open-source JS content editor that connects to
the real-time hosted API on <http://Sanity.io|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>
Looks like you already have a Sanity-account. Sweet!
✖ Fetching existing projects
Error: Failed to communicate with the Sanity API:
Unauthorized - Session not found. You may need to login again with sanity login.
For more information, see <https://docs.sanity.io/help/cli-errors>.
at getOrCreateProject (~/.npm/_npx/67a0730928194b24/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:44559:29)
at async getProjectDetails (~/.npm/_npx/67a0730928194b24/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:44521:21)
at async initSanity (~/.npm/_npx/67a0730928194b24/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:44316:108)
greggevorkyan@MacBook-Pro-6 modernbanc-sanity % npm sanity login
Unknown command: "sanity"
To see a list of supported npm commands, run:
npm helpMay 10, 2024, 11:09 PM
G
I just solved it by pre-installing sanity globally with
npm install sanity -gbut I wish it was in the docs.
May 10, 2024, 11:10 PM
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.
