🎤 Builder Talk: The Story Behind Lady Gaga’s Digital Experience – Register now

Error with reading property 'sanity' resolved by deleting node_modules and reinstalling packages

30 replies
Last updated: Feb 4, 2021
Uncaught error
Cannot read property 'sanity' of undefined

Stack:

TypeError: 
    at <https://dolcestilcriollo.sanity.studio/static/js/app.bundle.js?f8e5bbd157acfb86fc43:1163:3413841>
    at ye (<https://dolcestilcriollo.sanity.studio/static/js/app.bundle.js?f8e5bbd157acfb86fc43:30:552292>)
    at ye (<https://dolcestilcriollo.sanity.studio/static/js/app.bundle.js?f8e5bbd157acfb86fc43:30:552065>)
    at e.t.createStyles (<https://dolcestilcriollo.sanity.studio/static/js/app.bundle.js?f8e5bbd157acfb86fc43:30:558162>)
    at e.t.renderStyles (<https://dolcestilcriollo.sanity.studio/static/js/app.bundle.js?f8e5bbd157acfb86fc43:30:558401>)
    at u (<https://dolcestilcriollo.sanity.studio/static/js/app.bundle.js?f8e5bbd157acfb86fc43:30:558961>)
    at <https://dolcestilcriollo.sanity.studio/static/js/app.bundle.js?f8e5bbd157acfb86fc43:30:558777>
    at ro (<https://dolcestilcriollo.sanity.studio/static/js/vendor.bundle.js?2163562f6812e454f877:17:83208>)
    at lo (<https://dolcestilcriollo.sanity.studio/static/js/vendor.bundle.js?2163562f6812e454f877:17:83311>)
    at pu (<https://dolcestilcriollo.sanity.studio/static/js/vendor.bundle.js?2163562f6812e454f877:17:101245>)

(Your browsers Developer Tools may contain more info)
Feb 4, 2021, 7:12 PM
wild guess: have you set
project.basepath
in your sanity.json?
Feb 4, 2021, 7:14 PM
Currently:
Feb 4, 2021, 7:15 PM
"basePath": "/"
Feb 4, 2021, 7:15 PM
The setup is Gatsby in a web folder and the studio in a separate studio folder.
Feb 4, 2021, 7:16 PM
have you tried removing node_modules and package-lock and reinstall?
Feb 4, 2021, 7:17 PM
I am currently going through this process
Feb 4, 2021, 7:17 PM
I tried it another time already to no avail, but wanted to give it a shot again.
Feb 4, 2021, 7:17 PM
Give me a second. I will report back in a minute.
Feb 4, 2021, 7:18 PM
By the way, thank you a lot for jumping in that fast. You are awesome 🎉
Feb 4, 2021, 7:20 PM
So far still the same result, but I also can't find the node_module folder by any means. Is this referring to a node_module folder that should be generated by the studio or gatsby?
Feb 4, 2021, 7:23 PM
I didn't fire up gatsby so far, which should be no problem?
Feb 4, 2021, 7:24 PM
Additional info from the devtools:
Feb 4, 2021, 7:24 PM
The deploy doesn't complain and seems to be successful:
Feb 4, 2021, 7:25 PM
and are all your packages up to date?
Feb 4, 2021, 7:26 PM
sanity upgrade
Feb 4, 2021, 7:26 PM
I will run it 👍
Feb 4, 2021, 7:26 PM
Yes, they are.
Feb 4, 2021, 7:26 PM
everyone here suggests deleting node modules, but if that doesn't work… 😕 https://github.com/sanity-io/sanity/issues/2190
Feb 4, 2021, 7:28 PM
I went through that thread as well.
Feb 4, 2021, 7:28 PM
This is the only hit I got for this issue.
Feb 4, 2021, 7:28 PM
local build succeeds?
Feb 4, 2021, 7:28 PM
Yes
Feb 4, 2021, 7:28 PM
No warnings or anything.
Feb 4, 2021, 7:29 PM
I also deployed the studio to test, same issue.
Feb 4, 2021, 7:29 PM
Successful deploy, same error.
Feb 4, 2021, 7:29 PM
I've got to go, sorry! Maybe someone can else jump in 🙂
Feb 4, 2021, 7:30 PM
testCookie gives me a 404, that could be related?
Feb 4, 2021, 7:30 PM
Sure. Thank you for the input, Arjen!
Feb 4, 2021, 7:30 PM
Okay, resolved it. I thought, that the node_module folder wasn't initialized or that it simply would be somewhere else (who knows why), but I explicitly ignored it in vscodium. Node_module folder and package-lock.json deleted, reinstalled packages and it works like a charm (in Firefox at least, while Chromium just didn't want to accept the login cookie). Thank you for the input Arjen and I hope you excuse my silly oversight.
Feb 4, 2021, 7:48 PM
Great! Glad to hear you got it working 👍
Feb 4, 2021, 8:25 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?

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
How to turn PortableText into plain text in Javascript?Dec 7, 2020
DOMParser is not defined at defaultParseHtmlDec 3, 2020
Next.js and Vercel - Error! No Output Directory named "dist" foundAug 8, 2022
Custom Document Views - Is it Even Possible to Use the Structure Builder?Apr 21, 2022
GraphQL query resolving references on a _raw field in GatsbyMay 17, 2022
Hi all! Does anyone have problem on deoplloying on Vercel (Using Next. js as a frontend)? I have two test projects, andonce...Jan 25, 2021
Issue with compiling studio, resolved by nuking node_modules and installing with `sanity install`Aug 21, 2020
How to Disallow Robots on a SubdomainNov 12, 2020
Issue setting value of JSON field with document action in Sanity StudioApr 22, 2020
Error querying data from Sanity API in Gatsby componentMay 10, 2020

Related contributions

Turbo Start Sanity
- Template

The battle-tested Sanity template that powers Roboto Studio's websites

Go to Turbo Start Sanity

Schema UI - Next.js Sanity Starter
- Template

A Next.js starter template with Next.js 15, Tailwind CSS, shadcn/ui, and Sanity CMS with Live Editing. Get production-ready React components with matching Sanity schemas and queries. Build dynamic pages faster while keeping full control over customization.

Serge Ovcharenko
Go to Schema UI - Next.js Sanity Starter

The Swaddle
- Made with Sanity

A new brand identity to represent a more mature company, to signify The Swaddle’s evolution from publisher to production house, combined with an easier to navigate platform that can surface multiple content types - drawing readers through The Swaddle’s content offering.

Nightjar
Go to The Swaddle