Error deploying project to Vercel due to missing module '@sanity/cli'
3 replies
Last updated: Feb 25, 2023
R
hey guys,
I have a problem when I want to deploy it my project to vercel it gives me this error:
I don't know what to do anymore.
This are my package.json dependencies from sanity:
and from my nextjs:
I'm using nextjs 12 and not the sanity --version
@sanity/cli version 2.35.3
I have a problem when I want to deploy it my project to vercel it gives me this error:
./sanity/sanity.cli.ts:1:31 2023-02-25T16:10:48.112Z Type error: Cannot find module '@sanity/cli' or its corresponding type declarations. 2023-02-25T16:10:48.112Z 2023-02-25T16:10:48.112Z > 1 | import {defineCliConfig} from '@sanity/cli' 2023-02-25T16:10:48.114Z | ^ 2023-02-25T16:10:48.114Z 2 | 2023-02-25T16:10:48.114Z 3 | export default defineCliConfig({ 2023-02-25T16:10:48.114Z 4 | api: { 2023-02-25T16:10:48.165Z Error: Command "npm run build" exited with 1
This are my package.json dependencies from sanity:
"dependencies": { "@sanity/cli": "^3.4.0", "@sanity/vision": "^3.5.0", "react": "^18.2.0", "react-dom": "^18.2.0", "react-is": "^18.2.0", "sanity": "^3.0.0", "styled-components": "^5.2.0" }, "devDependencies": { "@sanity/eslint-config-studio": "^2.0.1", "eslint": "^8.6.0", "prettier": "^2.8.4", "typescript": "^4.0.0" },
"dependencies": { "@emailjs/browser": "^3.10.0", "@heroicons/react": "^2.0.15", "@portabletext/react": "^1.0.6", "@sanity/image-url": "^1.0.1", "framer-motion": "^9.0.2", "next": "^12.3.0", "next-sanity": "^1.1.0", "react": "18.2.0", "react-dom": "18.2.0", "react-hook-form": "^7.43.1", "react-simple-typewriter": "^5.0.1", "react-social-icons": "^5.15.0", "react-toastify": "^9.1.1" }, "devDependencies": { "@types/node": "18.13.0", "@types/react": "18.0.27", "@types/react-dom": "18.0.10", "autoprefixer": "^10.4.13", "eslint": "8.33.0", "eslint-config-next": "13.1.6", "postcss": "^8.4.21", "tailwind-scrollbar": "^2.1.0", "tailwindcss": "^3.2.6", "typescript": "4.9.5" }
@sanity/cli version 2.35.3
Feb 25, 2023, 4:17 PM
E
user Q
I’m on Svelte, not Nextjs, but I think the sanity.cli.tsfile should be similar. And in mine I have
import { defineCliConfig } from 'sanity/cli'
@. Does that work?
Feb 25, 2023, 5:10 PM
R
no, it doesn't work like that, I already tried it. I think I found the solution, I need it to move the dependencies from sanity package.json to next package.json and do a npm install in root to install them like so:
"dependencies": { "@emailjs/browser": "^3.10.0", "@heroicons/react": "^2.0.15", "@portabletext/react": "^1.0.6", "@sanity/image-url": "^1.0.1", "framer-motion": "^9.0.2", "next": "^12.3.0", "next-sanity": "^1.1.0", "react": "18.2.0", "react-dom": "18.2.0", "react-hook-form": "^7.43.1", "react-simple-typewriter": "^5.0.1", "react-social-icons": "^5.15.0", "react-toastify": "^9.1.1", "@sanity/vision": "^3.5.0", "sanity": "^3.0.0", "styled-components": "^5.2.0" }, "devDependencies": { "@sanity/eslint-config-studio": "^2.0.1", "@types/node": "18.13.0", "@types/react": "18.0.27", "@types/react-dom": "18.0.10", "autoprefixer": "^10.4.13", "eslint": "8.33.0", "eslint-config-next": "13.1.6", "postcss": "^8.4.21", "tailwind-scrollbar": "^2.1.0", "tailwindcss": "^3.2.6", "typescript": "4.9.5" }
Feb 25, 2023, 6:04 PM
R
basically copy
"sanity": "^3.0.0",
"styled-components": "^5.2.0"and
"@sanity/vision": "^3.5.0",in dependencies and
"@sanity/eslint-config-studio": "^2.0.1"in devDependencies in next package.json, run npm install in next project(not sanity) to install there the dependencies and I got thru that error
Feb 25, 2023, 6:08 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.