Error running "dev" command in Sanity project
15 replies
Last updated: Jan 18, 2023
A
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
:17880:2456)
Don't understand, it defintely has sanity as a dependency....
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
:17880:2456)
Don't understand, it defintely has sanity as a dependency....
Jan 18, 2023, 8:39 PM
R
Are you running the command from the right directory?
Jan 18, 2023, 8:42 PM
A
Hi
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
A
user M
Here is a screenshot, hope it helps.Thanks so much!!Jan 18, 2023, 8:48 PM
R
Very weird! What version of the CLI are you running?
Jan 18, 2023, 8:49 PM
A
"version": "3.2.3"
Jan 18, 2023, 8:50 PM
A
I know :face_with_peeking_eye:
Jan 18, 2023, 8:50 PM
R
What does your
package.jsonlook like?
Jan 18, 2023, 9:02 PM
A
Yes, it looks like this:
Jan 18, 2023, 9:14 PM
A
{
"private": true,
"name": "blog-with-gatsby-studio",
"main": "package.json",
"author": "Sanity <<mailto:hello@sanity.io|hello@sanity.io>>",
"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": [
"sanity"
],
"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
R
Maybe try deleting node modules and your package-lock then try reinstalling?
Jan 18, 2023, 9:34 PM
A
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
A
no idea what happened really
Jan 18, 2023, 9:35 PM
R
So weird!!
Jan 18, 2023, 9:35 PM
A
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
R
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.