Error running "dev" command in Sanity project

15 replies
Last updated: Jan 18, 2023
Hiya! Just started my project and i have this error:Error: Command "dev" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "sanity"
is installed as a dependency.
at CommandRunner.runCommand (~/Documents/GitHub/regi-khan/studio/node_modules/@sanity/cli/lib/_chunks/cli-0bbdf4ec.js
:17877:33701) at Object.runCli (~/Documents/GitHub/regi-khan/studio/node_modules/@sanity/cli/lib/_chunks/cli-0bbdf4ec.js
Don't understand, it defintely has sanity as a dependency....
Jan 18, 2023, 8:39 PM
Are you running the command from the right directory?
Jan 18, 2023, 8:42 PM
user M
! Yes indeed. So weird. Just checked and this only happens with the projects where i have sanity v3. Does that make sense?
Jan 18, 2023, 8:46 PM
user M
Here is a screenshot, hope it helps.Thanks so much!!
Jan 18, 2023, 8:48 PM
Very weird! What version of the CLI are you running?
Jan 18, 2023, 8:49 PM
"version": "3.2.3"
Jan 18, 2023, 8:50 PM
I know :face_with_peeking_eye:
Jan 18, 2023, 8:50 PM
What does your
look like?
Jan 18, 2023, 9:02 PM
Yes, it looks like this:
Jan 18, 2023, 9:14 PM

"private": true,

"name": "blog-with-gatsby-studio",

"main": "package.json",

"author": "Sanity &lt;<|>&gt;",

"scripts": {

"start": "sanity start",

"build": "sanity build",

"dev": "sanity dev",

"format": "prettier-eslint --write \"**/*.js\" \"!node_modules/**\"",

"graphql-deploy": "sanity graphql deploy",

"lint": "eslint .",

"test": "sanity check"


"keywords": [



"dependencies": {

"@react-md/icon": "^5.1.3",

"@sanity/dashboard": "^3.1.1",

"@sanity/vision": "^3.2.4",

"npm5": "^5.0.0-beta.69",

"prop-types": "^15.8.1",

"react": "^18.2.0",

"react-dom": "^18.2.0",

"react-icons": "^4.7.1",

"sanity": "^3.2.4",

"sanity-plugin-dashboard-widget-netlify": "^2.0.1",

"styled-components": "^5.3.3"


"devDependencies": {

"@babel/core": "^7.20.7",

"@babel/eslint-parser": "^7.19.1",

"eslint": "^8.31.0"


Jan 18, 2023, 9:14 PM
Maybe try deleting node modules and your package-lock then try reinstalling?
Jan 18, 2023, 9:34 PM
I did that before, but what actually solved it is that i created a new sanity studio project and after running that, the rest runned okay
Jan 18, 2023, 9:35 PM
no idea what happened really
Jan 18, 2023, 9:35 PM
So weird!!
Jan 18, 2023, 9:35 PM
i know 😞 was mega stressed. Happy that is solved now. Thanks for your help as well πŸ’› have a good night!
Jan 18, 2023, 9:36 PM
You too!
Jan 18, 2023, 10:03 PM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the 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?