✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Error encountered while deploying Sanity with Next.js, resolved by editing the baseURL.

7 replies
Last updated: Mar 18, 2024
Hey there! I'm currently using Sanity with Next.js, and upon running
npx sanity deploy

I'm getting the error below,

Error: [vite]: Rollup failed to resolve import "@/sanity/lib/api" from "/home/kane/code/fivepointfoodie/sanity.config.ts".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
Here is my
tsconfig.json
and
sanity.config
file!
Thank you!
Mar 18, 2024, 6:38 PM
Oops, and the
vite.config.js
Mar 18, 2024, 6:40 PM
Looks like
defineConfig
should be
defineCliConfig
.
Mar 18, 2024, 6:42 PM
Hey there! I tried that and I'm still receiving the same error
I recently created the
vite.config.js
and I believe the error has something to do with the
@/sanity/*
imports (Or Tailwind imports), but I don't want to update it to be
../../../
xD
Mar 18, 2024, 6:46 PM
Ah, this should be in your
sanity.cli.config
file I believe!
Mar 18, 2024, 6:47 PM
Here is the
sanity.config.ts
and here is the error
Hmm...
Mar 18, 2024, 6:54 PM
I got it! I edited the baseURL and got it!
Mar 18, 2024, 8:19 PM
Excellent!
Mar 18, 2024, 8:19 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?