sanity: Studio won't start (Uncaught TypeError: Cannot read property 'sanity' of undefined)
I’m getting the following when trying to run the latest version of Sanity:
Uncaught error
Cannot read property 'sanity' of undefined Stack: TypeError: at https://redacted.netlify.app/static/js/app.bundle.js?4c054893bbf7f9a02dc8:1262:130116 at be (https://redacted.netlify.app/static/js/app.bundle.js?4c054893bbf7f9a02dc8:90:138488) at be (https://redacted.netlify.app/static/js/app.bundle.js?4c054893bbf7f9a02dc8:90:138261) at e.t.createStyles (https://redacted.netlify.app/static/js/app.bundle.js?4c054893bbf7f9a02dc8:90:144358) at e.t.renderStyles (https://redacted.netlify.app/static/js/app.bundle.js?4c054893bbf7f9a02dc8:90:144597) at u (https://redacted.netlify.app/static/js/app.bundle.js?4c054893bbf7f9a02dc8:90:145157) at https://redacted.netlify.app/static/js/app.bundle.js?4c054893bbf7f9a02dc8:90:144973 at ro (https://redacted.netlify.app/static/js/vendor.bundle.js?3e9baa871d4a49047f70:22:83207) at lo (https://redacted.netlify.app/static/js/vendor.bundle.js?3e9baa871d4a49047f70:22:83310) at pu (https://redacted.netlify.app/static/js/vendor.bundle.js?3e9baa871d4a49047f70:22:101244) (Your browsers Developer Tools may contain more info)
This is where the error is occurring:
I think the problem might be this downgrade from @sanity/ui@1.0.0-beta.14
to @sanity/ui@0.28.0
:
https://github.com/sanity-io/sanity/pull/2183/files
Rolling back with npm i @sanity/base@2.0.9 @sanity/cli@2.0.9 @sanity/components@2.0.9 @sanity/core@2.0.9 @sanity/dashboard@2.0.9 @sanity/default-layout@2.0.9 @sanity/default-login@2.0.9 @sanity/desk-tool@2.0.9 @sanity/google-maps-input@2.0.9 @sanity/vision@2.0.9
resolves the issue.
Which versions of Sanity are you using?
"dependencies": {
"@sanity/base": "^2.1.2",
"@sanity/cli": "^2.1.0",
"@sanity/components": "^2.1.0",
"@sanity/core": "^2.1.2",
"@sanity/dashboard": "^2.1.0",
"@sanity/default-layout": "^2.1.2",
"@sanity/default-login": "^2.1.0",
"@sanity/desk-tool": "^2.1.2",
"@sanity/google-maps-input": "^2.1.2",
"@sanity/vision": "^2.1.0"
}
What operating system are you using?
Happens in Debian dev and Ubuntu build environments.
Which versions of Node.js / npm are you running?
6.14.8
v12.19.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 21 (4 by maintainers)
Deleting my
package-lock.json
and reinstalling from the existingpackage.json
successfully works around the issue.However, this should not be necessary, and I still think there is a broken dependency chain in Sanity.
Specifically:
"@sanity/desk-tool": "^2.1.3"
has dependency"@sanity/form-builder": "2.1.3"
"@sanity/form-builder": "2.1.3"
has dependency"@sanity/ui": "^0.28.0"
"@sanity/ui": "^0.28.0"
has peer dependency"styled-components": "^5.2"
"@sanity/form-builder": "2.1.3"
is not currently meeting this peer dependencyIf you meet the peer dependency, I believe you will solve the issue.
Found a potential cause of this issue on Sanity’s slack (if anyone else has this problem) : an object in the schema was missing a type.
I have no idea what causes it, but at least to me deleting
node_modules
and reruningyarn
seems to fix it (did it on two different projects).To anyone else still being bothered with this, try using
npm
instead ofyarn
.I’ve got one project where
sanity-plugin-media
works with yarn and another that refuses to work with yarn but works with npm. There are of course other differences in dependencies, but I’ll take the quickest route now and switch to npm where it helps. Maybe there’s time later to dig deeper.