🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Issue with running "sanity start" command in a project context

25 replies
Last updated: May 11, 2022
I'm having issues with running "sanity start" I am in the studio directory and I get the following error: Error: Command "start" is not available outside of a Sanity project context.Run the command again within a Sanity project directory, where "@sanity/core"
is installed as a dependency.
May 11, 2022, 3:50 PM
Hey there! It may be worth it to try running
sanity install
in the root of the directory once more. It's possible that it's listed as a dependency but not installed.
May 11, 2022, 6:17 PM
ok, i'll give it a shot now, thanks for replying
May 11, 2022, 6:19 PM
just did that and restarted vs code. Still same issue. So frustrating, I've been trying to search everywhere for a solution and nothing
May 11, 2022, 6:21 PM
also, it did work yesterday prior to me running npm run build
May 11, 2022, 6:22 PM
not sure if that did anything
May 11, 2022, 6:22 PM
It shouldn't. I've just tested it by running
npm run build
then
sanity start
. But to test, you can try deleting
dist
and
node_modules
and then reinstalling.
What does your folder structure look like? Is it possible you're using a monorepo and you're not in the right directory?
May 11, 2022, 6:26 PM
I've read about deleting dist and nod_modules, I haven't tried that yet.
May 11, 2022, 6:27 PM
I'm sure I'm in the right directory since I was able to use sanity start yesterday and for about a week.
May 11, 2022, 6:29 PM
but something must have went of of sync and I don't know what caused it
May 11, 2022, 6:29 PM
also when i ran npm run build i encounted an error so not sure if that messed things up
May 11, 2022, 6:33 PM
Do you remember what the error was?
May 11, 2022, 6:39 PM
I don't remember the error and I restarted the program so it's not in my history.
I just removed node modules via

rm -rf node_modules/
npm install
than reinstalled it.

I than ran sanity install and I still get the issue.

Error: Command "start" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "@sanity/core"
is installed as a dependency.

at _.runCommand (C:/nvm/v16.13.2/node_modules/@sanity/cli/bin/sanity-cli.js
:3614:1340) at t.exports (C:/nvm/v16.13.2/node_modules/@sanity/cli/bin/sanity-cli.js
:1986:2422)
May 11, 2022, 6:50 PM
I have 2 package.json files, One within the sanity project folder and the other in the Next.js folder
May 11, 2022, 7:03 PM
it shows that @sanity/core is in my package.json however it keeps showing that error when I run "sanity start"
May 11, 2022, 7:04 PM
It doesn't look like you're inside of a Studio directory. That looks like the structure of a Next project.
May 11, 2022, 7:08 PM
buzznextstudio is the sanity folder
May 11, 2022, 7:10 PM
I also noticed in the package.json within Studio project, "author": null, displays an error (Incorrect type. expected one of object, string
May 11, 2022, 7:11 PM
I meant buzznextsanity is the sanity folder I just pasted above
May 11, 2022, 7:12 PM
Your
sanity.json
isn't in the Sanity folder, it's inside of your Next project.
May 11, 2022, 7:13 PM
ok, I'll move it in the the sanity folder now
May 11, 2022, 7:13 PM
that's what my sanity.json file looks like.
May 11, 2022, 7:15 PM
I moved it into the buzznextsanity folder and I get this error
May 11, 2022, 7:17 PM
I downgraded to react 16.2 and still have the same error
Error: Command "start" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "@sanity/core"
is installed as a dependency.
May 11, 2022, 7:33 PM
and as shown in image above, @sanity/core 0.139.2 is the version
May 11, 2022, 7:34 PM
well, I sort of took a work around approach, I completely reinstalled from a backup and got it to work. I'm guessing it was something corrusted in the node modules
May 11, 2022, 9:37 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?